author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 6144 | 5a0ffbf27ced |
parent 6119 | b47985557d1e |
child 6195 | b90cf92697b9 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
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
|
3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1859
diff
changeset
|
4 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
5 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1309
diff
changeset
|
7 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
505
diff
changeset
|
8 |
#include "table/strings.h" |
588 | 9 |
#include "window.h" |
842 | 10 |
#include "gui.h" |
11 |
#include "command.h" |
|
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2154
diff
changeset
|
12 |
#include "variables.h" |
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2154
diff
changeset
|
13 |
#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
|
14 |
#include "newgrf_engine.h" |
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
15 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
16 |
|
6060
8388a1bcb7c8
(svn r8371) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni
parents:
6059
diff
changeset
|
17 |
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
|
18 |
|
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
19 |
static const StringID _rail_types_list[] = { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
20 |
STR_RAIL_VEHICLES, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
21 |
STR_ELRAIL_VEHICLES, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
22 |
STR_MONORAIL_VEHICLES, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
23 |
STR_MAGLEV_VEHICLES, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
24 |
INVALID_STRING_ID |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
25 |
}; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
26 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
27 |
/* General Vehicle GUI based procedures that are independent of vehicle types */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
28 |
void InitializeVehiclesGuiList(void) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
29 |
{ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
30 |
_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
|
31 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
32 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
33 |
// this define is to match engine.c, but engine.c keeps it to itself |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
34 |
// ENGINE_AVAILABLE is used in ReplaceVehicleWndProc |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
35 |
#define ENGINE_AVAILABLE ((e->flags & 1 && HASBIT(info->climates, _opt.landscape)) || HASBIT(e->player_avail, _local_player)) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
36 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
37 |
/* if show_outdated is selected, it do not sort psudo engines properly but it draws all engines |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
38 |
* if used compined with show_cars set to false, it will work as intended. Replace window do it like that |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
39 |
* this was a big hack even before show_outdated was added. Stupid newgrf :p |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
40 |
*/ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
41 |
static void train_engine_drawing_loop(int *x, int *y, int *pos, int *sel, EngineID *selected_id, RailType railtype, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
42 |
uint8 lines_drawn, bool is_engine, bool show_cars, bool show_outdated, bool show_compatible) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
43 |
{ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
44 |
EngineID j; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
45 |
byte colour; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
46 |
const Player *p = GetPlayer(_local_player); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
47 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
48 |
for (j = 0; j < NUM_TRAIN_ENGINES; j++) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
49 |
EngineID i = GetRailVehAtPosition(j); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
50 |
const Engine *e = GetEngine(i); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
51 |
const RailVehicleInfo *rvi = RailVehInfo(i); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
52 |
const EngineInfo *info = EngInfo(i); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
53 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
54 |
if (!EngineHasReplacementForPlayer(p, i) && p->num_engines[i] == 0 && show_outdated) continue; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
55 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
56 |
if ((rvi->power == 0 && !show_cars) || (rvi->power != 0 && show_cars)) // show wagons or engines (works since wagons do not have power) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
57 |
continue; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
58 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
59 |
if (*sel == 0) *selected_id = j; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
60 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
61 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
62 |
colour = *sel == 0 ? 0xC : 0x10; |
6074 | 63 |
if (!(ENGINE_AVAILABLE && show_outdated && RailVehInfo(i)->power && IsCompatibleRail(rvi->railtype, railtype))) { |
64 |
if ((!IsCompatibleRail(rvi->railtype, railtype) && show_compatible) |
|
65 |
|| (rvi->railtype != railtype && !show_compatible) |
|
6119
b47985557d1e
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
6074
diff
changeset
|
66 |
|| (rvi->railveh_type != RAILVEH_WAGON) != is_engine || |
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
67 |
!HASBIT(e->player_avail, _local_player)) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
68 |
continue; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
69 |
#if 0 |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
70 |
} else { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
71 |
// TODO find a nice red colour for vehicles being replaced |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
72 |
if ( _autoreplace_array[i] != i ) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
73 |
colour = *sel == 0 ? 0x44 : 0x45; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
74 |
#endif |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
75 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
76 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
77 |
if (IS_INT_INSIDE(--*pos, -lines_drawn, 0)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
78 |
DrawString(*x + 59, *y + 2, GetCustomEngineName(i), |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
79 |
colour); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
80 |
// show_outdated is true only for left side, which is where we show old replacements |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
81 |
DrawTrainEngine(*x + 29, *y + 6, i, (p->num_engines[i] == 0 && show_outdated) ? |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
82 |
PALETTE_CRASH : GetEnginePalette(i, _local_player)); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
83 |
if ( show_outdated ) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
84 |
SetDParam(0, p->num_engines[i]); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
85 |
DrawStringRightAligned(213, *y+5, STR_TINY_BLACK, 0); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
86 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
87 |
*y += 14; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
88 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
89 |
--*sel; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
90 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
91 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
92 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
93 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
94 |
static void SetupScrollStuffForReplaceWindow(Window *w) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
95 |
{ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
96 |
EngineID selected_id[2] = { INVALID_ENGINE, INVALID_ENGINE }; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
97 |
const Player* p = GetPlayer(_local_player); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
98 |
uint sel[2]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
99 |
uint count = 0; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
100 |
uint count2 = 0; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
101 |
EngineID i; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
102 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
103 |
sel[0] = WP(w,replaceveh_d).sel_index[0]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
104 |
sel[1] = WP(w,replaceveh_d).sel_index[1]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
105 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
106 |
switch (WP(w,replaceveh_d).vehicletype) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
107 |
case VEH_Train: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
108 |
RailType railtype = _railtype_selected_in_replace_gui; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
109 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
110 |
w->widget[13].color = _player_colors[_local_player]; // sets the colour of that art thing |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
111 |
w->widget[16].color = _player_colors[_local_player]; // sets the colour of that art thing |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
112 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
113 |
for (i = 0; i < NUM_TRAIN_ENGINES; i++) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
114 |
EngineID eid = GetRailVehAtPosition(i); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
115 |
const Engine* e = GetEngine(eid); |
6074 | 116 |
const RailVehicleInfo *rvi = RailVehInfo(eid); |
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
117 |
const EngineInfo* info = EngInfo(eid); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
118 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
119 |
// left window contains compatible engines while right window only contains engines of the selected type |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
120 |
if (ENGINE_AVAILABLE && |
6074 | 121 |
(rvi->power != 0) == (WP(w, replaceveh_d).wagon_btnstate != 0)) { |
122 |
if (IsCompatibleRail(rvi->railtype, railtype) && (p->num_engines[eid] > 0 || EngineHasReplacementForPlayer(p, eid))) { |
|
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
123 |
if (sel[0] == count) selected_id[0] = eid; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
124 |
count++; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
125 |
} |
6074 | 126 |
if (rvi->railtype == railtype && HASBIT(e->player_avail, _local_player)) { |
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
127 |
if (sel[1] == count2) selected_id[1] = eid; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
128 |
count2++; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
129 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
130 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
131 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
132 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
133 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
134 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
135 |
case VEH_Road: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
136 |
for (i = ROAD_ENGINES_INDEX; i < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; i++) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
137 |
if (p->num_engines[i] > 0 || EngineHasReplacementForPlayer(p, i)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
138 |
if (sel[0] == count) selected_id[0] = i; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
139 |
count++; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
140 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
141 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
142 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
143 |
if (selected_id[0] != INVALID_ENGINE) { // only draw right array if we have anything in the left one |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
144 |
CargoID cargo = RoadVehInfo(selected_id[0])->cargo_type; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
145 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
146 |
for (i = ROAD_ENGINES_INDEX; i < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; i++) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
147 |
if (cargo == RoadVehInfo(i)->cargo_type && |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
148 |
HASBIT(GetEngine(i)->player_avail, _local_player)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
149 |
if (sel[1] == count2) selected_id[1] = i; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
150 |
count2++; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
151 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
152 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
153 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
154 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
155 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
156 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
157 |
case VEH_Ship: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
158 |
for (i = SHIP_ENGINES_INDEX; i < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; i++) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
159 |
if (p->num_engines[i] > 0 || EngineHasReplacementForPlayer(p, i)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
160 |
if (sel[0] == count) selected_id[0] = i; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
161 |
count++; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
162 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
163 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
164 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
165 |
if (selected_id[0] != INVALID_ENGINE) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
166 |
const ShipVehicleInfo* svi = ShipVehInfo(selected_id[0]); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
167 |
CargoID cargo = svi->cargo_type; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
168 |
bool refittable = svi->refittable; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
169 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
170 |
for (i = SHIP_ENGINES_INDEX; i < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; i++) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
171 |
if (HASBIT(GetEngine(i)->player_avail, _local_player) && ( |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
172 |
ShipVehInfo(i)->cargo_type == cargo || |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
173 |
ShipVehInfo(i)->refittable && refittable |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
174 |
)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
175 |
if (sel[1] == count2) selected_id[1] = i; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
176 |
count2++; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
177 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
178 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
179 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
180 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
181 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
182 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
183 |
case VEH_Aircraft: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
184 |
for (i = AIRCRAFT_ENGINES_INDEX; i < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; i++) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
185 |
if (p->num_engines[i] > 0 || EngineHasReplacementForPlayer(p, i)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
186 |
if (sel[0] == count) selected_id[0] = i; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
187 |
count++; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
188 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
189 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
190 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
191 |
if (selected_id[0] != INVALID_ENGINE) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
192 |
byte subtype = AircraftVehInfo(selected_id[0])->subtype; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
193 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
194 |
for (i = AIRCRAFT_ENGINES_INDEX; i < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; i++) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
195 |
if (HASBIT(GetEngine(i)->player_avail, _local_player) && |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
196 |
(subtype & AIR_CTOL) == (AircraftVehInfo(i)->subtype & AIR_CTOL)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
197 |
if (sel[1] == count2) selected_id[1] = i; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
198 |
count2++; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
199 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
200 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
201 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
202 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
203 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
204 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
205 |
// sets up the number of items in each list |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
206 |
SetVScrollCount(w, count); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
207 |
SetVScroll2Count(w, count2); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
208 |
WP(w,replaceveh_d).sel_engine[0] = selected_id[0]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
209 |
WP(w,replaceveh_d).sel_engine[1] = selected_id[1]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
210 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
211 |
WP(w,replaceveh_d).count[0] = count; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
212 |
WP(w,replaceveh_d).count[1] = count2; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
213 |
return; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
214 |
} |
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 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
217 |
static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int y2, int pos, int pos2, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
218 |
int sel1, int sel2, EngineID selected_id1, EngineID selected_id2) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
219 |
{ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
220 |
int sel[2]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
221 |
EngineID selected_id[2]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
222 |
const Player *p = GetPlayer(_local_player); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
223 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
224 |
sel[0] = sel1; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
225 |
sel[1] = sel2; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
226 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
227 |
selected_id[0] = selected_id1; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
228 |
selected_id[1] = selected_id2; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
229 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
230 |
switch (WP(w,replaceveh_d).vehicletype) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
231 |
case VEH_Train: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
232 |
RailType railtype = _railtype_selected_in_replace_gui; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
233 |
DrawString(157, w->widget[14].top + 1, _rail_types_list[railtype], 0x10); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
234 |
/* draw sorting criteria string */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
235 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
236 |
/* Ensure that custom engines which substituted wagons |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
237 |
* are sorted correctly. |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
238 |
* XXX - DO NOT EVER DO THIS EVER AGAIN! GRRR hacking in wagons as |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
239 |
* engines to get more types.. Stays here until we have our own format |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
240 |
* then it is exit!!! */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
241 |
if (WP(w,replaceveh_d).wagon_btnstate) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
242 |
train_engine_drawing_loop(&x, &y, &pos, &sel[0], &selected_id[0], railtype, w->vscroll.cap, true, false, true, true); // True engines |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
243 |
train_engine_drawing_loop(&x2, &y2, &pos2, &sel[1], &selected_id[1], railtype, w->vscroll.cap, true, false, false, false); // True engines |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
244 |
train_engine_drawing_loop(&x2, &y2, &pos2, &sel[1], &selected_id[1], railtype, w->vscroll.cap, false, false, false, false); // Feeble wagons |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
245 |
} else { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
246 |
train_engine_drawing_loop(&x, &y, &pos, &sel[0], &selected_id[0], railtype, w->vscroll.cap, false, true, true, true); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
247 |
train_engine_drawing_loop(&x2, &y2, &pos2, &sel[1], &selected_id[1], railtype, w->vscroll.cap, false, true, false, true); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
248 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
249 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
250 |
} |
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 |
case VEH_Road: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
253 |
int num = NUM_ROAD_ENGINES; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
254 |
const Engine* e = GetEngine(ROAD_ENGINES_INDEX); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
255 |
EngineID engine_id = ROAD_ENGINES_INDEX; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
256 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
257 |
do { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
258 |
if (p->num_engines[engine_id] > 0 || EngineHasReplacementForPlayer(p, engine_id)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
259 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
260 |
DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel[0]==0 ? 0xC : 0x10); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
261 |
DrawRoadVehEngine(x+29, y+6, engine_id, p->num_engines[engine_id] > 0 ? GetEnginePalette(engine_id, _local_player) : PALETTE_CRASH); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
262 |
SetDParam(0, p->num_engines[engine_id]); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
263 |
DrawStringRightAligned(213, y+5, STR_TINY_BLACK, 0); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
264 |
y += 14; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
265 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
266 |
sel[0]--; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
267 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
268 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
269 |
if (selected_id[0] != INVALID_ENGINE) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
270 |
byte cargo = RoadVehInfo(selected_id[0])->cargo_type; |
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 |
if (RoadVehInfo(engine_id)->cargo_type == cargo && HASBIT(e->player_avail, _local_player)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
273 |
if (IS_INT_INSIDE(--pos2, -w->vscroll.cap, 0) && RoadVehInfo(engine_id)->cargo_type == cargo) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
274 |
DrawString(x2+59, y2+2, GetCustomEngineName(engine_id), sel[1]==0 ? 0xC : 0x10); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
275 |
DrawRoadVehEngine(x2+29, y2+6, engine_id, GetEnginePalette(engine_id, _local_player)); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
276 |
y2 += 14; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
277 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
278 |
sel[1]--; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
279 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
280 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
281 |
} while (++engine_id, ++e,--num); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
282 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
283 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
284 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
285 |
case VEH_Ship: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
286 |
int num = NUM_SHIP_ENGINES; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
287 |
const Engine* e = GetEngine(SHIP_ENGINES_INDEX); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
288 |
EngineID engine_id = SHIP_ENGINES_INDEX; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
289 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
290 |
do { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
291 |
if (p->num_engines[engine_id] > 0 || EngineHasReplacementForPlayer(p, engine_id)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
292 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
293 |
DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel[0]==0 ? 0xC : 0x10); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
294 |
DrawShipEngine(x+35, y+10, engine_id, p->num_engines[engine_id] > 0 ? GetEnginePalette(engine_id, _local_player) : PALETTE_CRASH); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
295 |
SetDParam(0, p->num_engines[engine_id]); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
296 |
DrawStringRightAligned(213, y+15, STR_TINY_BLACK, 0); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
297 |
y += 24; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
298 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
299 |
sel[0]--; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
300 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
301 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
302 |
if (selected_id[0] != INVALID_ENGINE) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
303 |
CargoID cargo = ShipVehInfo(selected_id[0])->cargo_type; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
304 |
bool refittable = ShipVehInfo(selected_id[0])->refittable; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
305 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
306 |
if (HASBIT(e->player_avail, _local_player) && ( cargo == ShipVehInfo(engine_id)->cargo_type || refittable & ShipVehInfo(engine_id)->refittable)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
307 |
if (IS_INT_INSIDE(--pos2, -w->vscroll.cap, 0)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
308 |
DrawString(x2+75, y2+7, GetCustomEngineName(engine_id), sel[1]==0 ? 0xC : 0x10); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
309 |
DrawShipEngine(x2+35, y2+10, engine_id, GetEnginePalette(engine_id, _local_player)); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
310 |
y2 += 24; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
311 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
312 |
sel[1]--; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
313 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
314 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
315 |
} while (++engine_id, ++e, --num); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
316 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
317 |
} //end of ship |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
318 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
319 |
case VEH_Aircraft: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
320 |
int num = NUM_AIRCRAFT_ENGINES; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
321 |
const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
322 |
EngineID engine_id = AIRCRAFT_ENGINES_INDEX; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
323 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
324 |
do { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
325 |
if (p->num_engines[engine_id] > 0 || EngineHasReplacementForPlayer(p, engine_id)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
326 |
if (sel[0] == 0) selected_id[0] = engine_id; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
327 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
328 |
DrawString(x+62, y+7, GetCustomEngineName(engine_id), sel[0]==0 ? 0xC : 0x10); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
329 |
DrawAircraftEngine(x+29, y+10, engine_id, p->num_engines[engine_id] > 0 ? GetEnginePalette(engine_id, _local_player) : PALETTE_CRASH); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
330 |
SetDParam(0, p->num_engines[engine_id]); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
331 |
DrawStringRightAligned(213, y+15, STR_TINY_BLACK, 0); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
332 |
y += 24; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
333 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
334 |
sel[0]--; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
335 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
336 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
337 |
if (selected_id[0] != INVALID_ENGINE) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
338 |
byte subtype = AircraftVehInfo(selected_id[0])->subtype; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
339 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
340 |
if ((subtype & AIR_CTOL) == (AircraftVehInfo(engine_id)->subtype & AIR_CTOL) && |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
341 |
HASBIT(e->player_avail, _local_player)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
342 |
if (sel[1] == 0) selected_id[1] = engine_id; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
343 |
if (IS_INT_INSIDE(--pos2, -w->vscroll.cap, 0)) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
344 |
DrawString(x2+62, y2+7, GetCustomEngineName(engine_id), sel[1]==0 ? 0xC : 0x10); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
345 |
DrawAircraftEngine(x2+29, y2+10, engine_id, GetEnginePalette(engine_id, _local_player)); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
346 |
y2 += 24; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
347 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
348 |
sel[1]--; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
349 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
350 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
351 |
} while (++engine_id, ++e,--num); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
352 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
353 |
} // end of aircraft |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
354 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
355 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
356 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
357 |
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
|
358 |
{ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
359 |
static const StringID _vehicle_type_names[] = { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
360 |
STR_019F_TRAIN, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
361 |
STR_019C_ROAD_VEHICLE, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
362 |
STR_019E_SHIP, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
363 |
STR_019D_AIRCRAFT |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
364 |
}; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
365 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
366 |
switch (e->event) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
367 |
case WE_PAINT: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
368 |
Player *p = GetPlayer(_local_player); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
369 |
int pos = w->vscroll.pos; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
370 |
EngineID selected_id[2] = { INVALID_ENGINE, INVALID_ENGINE }; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
371 |
int x = 1; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
372 |
int y = 15; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
373 |
int pos2 = w->vscroll2.pos; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
374 |
int x2 = 1 + 228; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
375 |
int y2 = 15; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
376 |
int sel[2]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
377 |
byte i; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
378 |
sel[0] = WP(w,replaceveh_d).sel_index[0]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
379 |
sel[1] = WP(w,replaceveh_d).sel_index[1]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
380 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
381 |
SetupScrollStuffForReplaceWindow(w); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
382 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
383 |
selected_id[0] = 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
|
384 |
selected_id[1] = WP(w,replaceveh_d).sel_engine[1]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
385 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
386 |
// Disable the "Start Replacing" button if: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
387 |
// Either list is empty |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
388 |
// or Both lists have the same vehicle selected |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
389 |
// or The selected replacement engine has a replacement (to prevent loops) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
390 |
// or The right list (new replacement) has the existing replacement vehicle selected |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
391 |
SetWindowWidgetDisabledState(w, 4, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
392 |
selected_id[0] == INVALID_ENGINE || |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
393 |
selected_id[1] == INVALID_ENGINE || |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
394 |
selected_id[0] == selected_id[1] || |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
395 |
EngineReplacementForPlayer(p, selected_id[1]) != INVALID_ENGINE || |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
396 |
EngineReplacementForPlayer(p, selected_id[0]) == selected_id[1]); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
397 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
398 |
// Disable the "Stop Replacing" button if: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
399 |
// The left list (existing vehicle) is empty |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
400 |
// or The selected vehicle has no replacement set up |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
401 |
SetWindowWidgetDisabledState(w, 6, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
402 |
selected_id[0] == INVALID_ENGINE || |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
403 |
!EngineHasReplacementForPlayer(p, selected_id[0])); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
404 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
405 |
// now the actual drawing of the window itself takes place |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
406 |
SetDParam(0, _vehicle_type_names[WP(w, replaceveh_d).vehicletype - VEH_Train]); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
407 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
408 |
if (WP(w, replaceveh_d).vehicletype == VEH_Train) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
409 |
// set on/off for renew_keep_length |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
410 |
SetDParam(1, p->renew_keep_length ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
411 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
412 |
// set wagon/engine button |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
413 |
SetDParam(2, WP(w, replaceveh_d).wagon_btnstate ? STR_ENGINES : STR_WAGONS); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
414 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
415 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
416 |
DrawWindowWidgets(w); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
417 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
418 |
// sets up the string for the vehicle that is being replaced to |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
419 |
if (selected_id[0] != INVALID_ENGINE) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
420 |
if (!EngineHasReplacementForPlayer(p, selected_id[0])) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
421 |
SetDParam(0, STR_NOT_REPLACING); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
422 |
} else { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
423 |
SetDParam(0, GetCustomEngineName(EngineReplacementForPlayer(p, selected_id[0]))); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
424 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
425 |
} else { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
426 |
SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
427 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
428 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
429 |
DrawString(145, w->widget[5].top + 1, STR_02BD, 0x10); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
430 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
431 |
/* now we draw the two arrays according to what we just counted */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
432 |
DrawEngineArrayInReplaceWindow(w, x, y, x2, y2, pos, pos2, sel[0], sel[1], selected_id[0], selected_id[1]); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
433 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
434 |
WP(w,replaceveh_d).sel_engine[0] = selected_id[0]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
435 |
WP(w,replaceveh_d).sel_engine[1] = selected_id[1]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
436 |
/* now we draw the info about the vehicles we selected */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
437 |
for (i = 0 ; i < 2 ; i++) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
438 |
if (selected_id[i] != INVALID_ENGINE) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
439 |
const Widget *wi = &w->widget[i == 0 ? 3 : 11]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
440 |
DrawVehiclePurchaseInfo(wi->left + 2 , wi->top + 1, wi->right - wi->left - 2, selected_id[i]); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
441 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
442 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
443 |
} break; // end of paint |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
444 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
445 |
case WE_CLICK: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
446 |
// these 3 variables is used if any of the lists is clicked |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
447 |
uint16 click_scroll_pos = w->vscroll2.pos; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
448 |
uint16 click_scroll_cap = w->vscroll2.cap; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
449 |
byte click_side = 1; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
450 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
451 |
switch (e->we.click.widget) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
452 |
case 12: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
453 |
WP(w, replaceveh_d).wagon_btnstate = !(WP(w, replaceveh_d).wagon_btnstate); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
454 |
SetWindowDirty(w); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
455 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
456 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
457 |
case 14: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
458 |
case 15: /* Railtype selection dropdown menu */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
459 |
ShowDropDownMenu(w, _rail_types_list, _railtype_selected_in_replace_gui, 15, 0, ~GetPlayer(_local_player)->avail_railtypes); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
460 |
break; |
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 |
case 17: /* toggle renew_keep_length */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
463 |
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
|
464 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
465 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
466 |
case 4: { /* Start replacing */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
467 |
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
|
468 |
EngineID veh_to = WP(w, replaceveh_d).sel_engine[1]; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
469 |
DoCommandP(0, 3, veh_from + (veh_to << 16), NULL, CMD_SET_AUTOREPLACE); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
470 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
471 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
472 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
473 |
case 6: { /* Stop replacing */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
474 |
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
|
475 |
DoCommandP(0, 3, veh_from + (INVALID_ENGINE << 16), NULL, CMD_SET_AUTOREPLACE); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
476 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
477 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
478 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
479 |
case 7: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
480 |
// sets up that the left one was clicked. The default values are for the right one (9) |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
481 |
// this way, the code for 9 handles both sides |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
482 |
click_scroll_pos = w->vscroll.pos; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
483 |
click_scroll_cap = w->vscroll.cap; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
484 |
click_side = 0; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
485 |
/* FALL THROUGH */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
486 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
487 |
case 9: { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
488 |
uint i = (e->we.click.pt.y - 14) / w->resize.step_height; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
489 |
if (i < click_scroll_cap) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
490 |
WP(w,replaceveh_d).sel_index[click_side] = i + click_scroll_pos; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
491 |
SetWindowDirty(w); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
492 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
493 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
494 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
495 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
496 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
497 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
498 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
499 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
500 |
_railtype_selected_in_replace_gui = (RailType)e->we.dropdown.index; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
501 |
/* Reset scrollbar positions */ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
502 |
w->vscroll.pos = 0; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
503 |
w->vscroll2.pos = 0; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
504 |
SetWindowDirty(w); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
505 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
506 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
507 |
case WE_RESIZE: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
508 |
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
|
509 |
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
|
510 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
511 |
w->widget[7].data = (w->vscroll.cap << 8) + 1; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
512 |
w->widget[9].data = (w->vscroll2.cap << 8) + 1; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
513 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
514 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
515 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
516 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
517 |
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
|
518 |
{ 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
|
519 |
{ 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
|
520 |
{ 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
|
521 |
{ 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
|
522 |
{ 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
|
523 |
{ 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
|
524 |
{ 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
|
525 |
{ 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
|
526 |
{ 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
|
527 |
{ 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
|
528 |
{ 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
|
529 |
{ 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
|
530 |
// train specific stuff |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
531 |
{ 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
|
532 |
{ WWT_PANEL, RESIZE_TB, 14, 139, 153, 240, 251, 0x0, STR_NULL}, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
533 |
{ WWT_PANEL, RESIZE_TB, 14, 154, 277, 240, 251, 0x0, STR_REPLACE_HELP_RAILTYPE}, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
534 |
{ WWT_TEXTBTN, RESIZE_TB, 14, 278, 289, 240, 251, STR_0225, STR_REPLACE_HELP_RAILTYPE}, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
535 |
{ 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
|
536 |
{ 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
|
537 |
// end of train specific stuff |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
538 |
{ 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
|
539 |
{ WIDGETS_END}, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
540 |
}; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
541 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
542 |
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
|
543 |
{ 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
|
544 |
{ 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
|
545 |
{ 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
|
546 |
{ 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
|
547 |
{ 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
|
548 |
{ 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
|
549 |
{ 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
|
550 |
{ 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
|
551 |
{ 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
|
552 |
{ 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
|
553 |
{ 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
|
554 |
{ 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
|
555 |
{ 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
|
556 |
{ WIDGETS_END}, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
557 |
}; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
558 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
559 |
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
|
560 |
{ 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
|
561 |
{ 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
|
562 |
{ 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
|
563 |
{ 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
|
564 |
{ 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
|
565 |
{ 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
|
566 |
{ 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
|
567 |
{ 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
|
568 |
{ 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
|
569 |
{ 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
|
570 |
{ 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
|
571 |
{ 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
|
572 |
{ 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
|
573 |
{ WIDGETS_END}, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
574 |
}; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
575 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
576 |
static const WindowDesc _replace_rail_vehicle_desc = { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
577 |
WDP_AUTO, WDP_AUTO, 456, 252, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6119
diff
changeset
|
578 |
WC_REPLACE_VEHICLE, WC_NONE, |
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
579 |
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
|
580 |
_replace_rail_vehicle_widgets, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
581 |
ReplaceVehicleWndProc |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
582 |
}; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
583 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
584 |
static const WindowDesc _replace_road_vehicle_desc = { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
585 |
WDP_AUTO, WDP_AUTO, 456, 230, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6119
diff
changeset
|
586 |
WC_REPLACE_VEHICLE, WC_NONE, |
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
587 |
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
|
588 |
_replace_road_vehicle_widgets, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
589 |
ReplaceVehicleWndProc |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
590 |
}; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
591 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
592 |
static const WindowDesc _replace_ship_aircraft_vehicle_desc = { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
593 |
WDP_AUTO, WDP_AUTO, 456, 214, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6119
diff
changeset
|
594 |
WC_REPLACE_VEHICLE, WC_NONE, |
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
595 |
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
|
596 |
_replace_ship_aircraft_vehicle_widgets, |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
597 |
ReplaceVehicleWndProc |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
598 |
}; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
599 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
600 |
|
6060
8388a1bcb7c8
(svn r8371) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni
parents:
6059
diff
changeset
|
601 |
void ShowReplaceVehicleWindow(byte vehicletype) |
6059
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
602 |
{ |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
603 |
Window *w; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
604 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
605 |
DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
606 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
607 |
switch (vehicletype) { |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
608 |
case VEH_Train: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
609 |
w = AllocateWindowDescFront(&_replace_rail_vehicle_desc, vehicletype); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
610 |
w->vscroll.cap = 8; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
611 |
w->resize.step_height = 14; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
612 |
WP(w, replaceveh_d).wagon_btnstate = true; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
613 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
614 |
case VEH_Road: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
615 |
w = AllocateWindowDescFront(&_replace_road_vehicle_desc, vehicletype); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
616 |
w->vscroll.cap = 8; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
617 |
w->resize.step_height = 14; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
618 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
619 |
case VEH_Ship: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
620 |
case VEH_Aircraft: |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
621 |
w = AllocateWindowDescFront(&_replace_ship_aircraft_vehicle_desc, vehicletype); |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
622 |
w->vscroll.cap = 4; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
623 |
w->resize.step_height = 24; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
624 |
break; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
625 |
default: return; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
626 |
} |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
627 |
|
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
628 |
w->caption_color = _local_player; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
629 |
WP(w, replaceveh_d).vehicletype = vehicletype; |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
630 |
w->vscroll2.cap = w->vscroll.cap; // these two are always the same |
14d457867d5e
(svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents:
6052
diff
changeset
|
631 |
} |