author | Darkvater |
Mon, 31 Jul 2006 22:40:55 +0000 | |
changeset 4204 | 3aa39be759f2 |
parent 4171 | 5c6e60c392c3 |
child 4243 | b0361faa4dfd |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
4 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
5 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
3959 | 7 |
#include "roadveh.h" |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
8 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
374
diff
changeset
|
9 |
#include "table/strings.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
671
diff
changeset
|
10 |
#include "map.h" |
0 | 11 |
#include "window.h" |
12 |
#include "gui.h" |
|
13 |
#include "gfx.h" |
|
14 |
#include "vehicle.h" |
|
15 |
#include "viewport.h" |
|
16 |
#include "station.h" |
|
17 |
#include "command.h" |
|
18 |
#include "player.h" |
|
19 |
#include "engine.h" |
|
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
20 |
#include "depot.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2113
diff
changeset
|
21 |
#include "vehicle_gui.h" |
2962
f0a49b646c48
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2958
diff
changeset
|
22 |
#include "newgrf_engine.h" |
0 | 23 |
|
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
24 |
/** |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
25 |
* Draw the purchase info details of road vehicle at a given location. |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
26 |
* @param x,y location where to draw the info |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
27 |
* @param engine_number the engine of which to draw the info of |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
28 |
*/ |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
29 |
void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number) |
842 | 30 |
{ |
31 |
const RoadVehicleInfo *rvi = RoadVehInfo(engine_number); |
|
4171 | 32 |
const Engine *e = GetEngine(engine_number); |
3990
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
33 |
bool refittable = (_engine_info[engine_number].refit_mask != 0); |
842 | 34 |
YearMonthDay ymd; |
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
35 |
ConvertDayToYMD(&ymd, e->intro_date); |
842 | 36 |
|
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
37 |
/* Purchase cost - Max speed */ |
842 | 38 |
SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3431
diff
changeset
|
39 |
SetDParam(1, rvi->max_speed / 2); |
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
40 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
41 |
y += 10; |
842 | 42 |
|
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
43 |
/* Running cost */ |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
44 |
SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
45 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
46 |
y += 10; |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
47 |
|
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
48 |
/* Cargo type + capacity */ |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1986
diff
changeset
|
49 |
SetDParam(0, _cargoc.names_long[rvi->cargo_type]); |
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
50 |
SetDParam(1, rvi->capacity); |
3990
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
51 |
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
52 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
53 |
y += 10; |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
54 |
|
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
55 |
/* Design date - Life length */ |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
56 |
SetDParam(0, ymd.year + 1920); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
57 |
SetDParam(1, e->lifelength); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
58 |
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
59 |
y += 10; |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
60 |
|
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
61 |
/* Reliability */ |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
62 |
SetDParam(0, e->reliability * 100 >> 16); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
63 |
DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, 0); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
64 |
y += 10; |
842 | 65 |
} |
66 |
||
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
67 |
static void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection) |
0 | 68 |
{ |
3049
d6109b5fd55d
(svn r3631) - 2cc: Remove use of some temporary variables and perform minor optimization in the form of the ternary operator.
peter1138
parents:
3040
diff
changeset
|
69 |
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3049
diff
changeset
|
70 |
DrawSprite(GetRoadVehImage(v, DIR_W) | pal, x + 14, y + 6); |
0 | 71 |
|
72 |
if (v->index == selection) { |
|
2639 | 73 |
DrawFrameRect(x - 1, y - 1, x + 28, y + 12, 15, FR_BORDERONLY); |
0 | 74 |
} |
75 |
} |
|
76 |
||
3990
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
77 |
static void RoadVehRefitWndProc(Window *w, WindowEvent *e) |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
78 |
{ |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
79 |
switch (e->event) { |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
80 |
case WE_PAINT: { |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
81 |
const Vehicle *v = GetVehicle(w->window_number); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
82 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
83 |
SetDParam(0, v->string_id); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
84 |
SetDParam(1, v->unitnumber); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
85 |
DrawWindowWidgets(w); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
86 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
87 |
DrawString(1, 15, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, 0); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
88 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
89 |
WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w,refit_d).sel); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
90 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
91 |
if (WP(w,refit_d).cargo != CT_INVALID) { |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
92 |
int32 cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_ROAD_VEH); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
93 |
if (!CmdFailed(cost)) { |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
94 |
SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
95 |
SetDParam(1, _returned_refit_capacity); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
96 |
SetDParam(2, cost); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
97 |
DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
98 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
99 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
100 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
101 |
break; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
102 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
103 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
104 |
case WE_CLICK: |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
105 |
switch (e->click.widget) { |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
106 |
case 2: { /* List box */ |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
107 |
int y = e->click.pt.y - 25; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
108 |
if (y >= 0) { |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
109 |
WP(w,refit_d).sel = y / 10; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
110 |
SetWindowDirty(w); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
111 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
112 |
break; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
113 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
114 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
115 |
case 4: /* Refit button */ |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
116 |
if (WP(w,refit_d).cargo != CT_INVALID) { |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
117 |
const Vehicle *v = GetVehicle(w->window_number); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
118 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_ROAD_VEH | CMD_MSG(STR_REFIT_ROAD_VEHICLE_CAN_T))) |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
119 |
DeleteWindow(w); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
120 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
121 |
break; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
122 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
123 |
break; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
124 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
125 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
126 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
127 |
static const Widget _road_veh_refit_widgets[] = { |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
128 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
129 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_983B_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
130 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 135, 0x0, STR_983D_SELECT_TYPE_OF_CARGO_FOR }, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
131 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 136, 157, 0x0, STR_NULL }, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
132 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 158, 169, STR_REFIT_ROAD_VEHICLE, STR_REFIT_ROAD_VEHICLE_TO_CARRY_HIGHLIGHTED }, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
133 |
{ WIDGETS_END }, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
134 |
}; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
135 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
136 |
static const WindowDesc _road_veh_refit_desc = { |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
137 |
-1, -1, 240, 170, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
138 |
WC_VEHICLE_REFIT, WC_VEHICLE_VIEW, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
139 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
140 |
_road_veh_refit_widgets, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
141 |
RoadVehRefitWndProc, |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
142 |
}; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
143 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
144 |
static void ShowRoadVehRefitWindow(const Vehicle *v) |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
145 |
{ |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
146 |
Window *w; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
147 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
148 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
149 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
150 |
_alloc_wnd_parent_num = v->index; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
151 |
w = AllocateWindowDesc(&_road_veh_refit_desc); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
152 |
w->window_number = v->index; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
153 |
w->caption_color = v->owner; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
154 |
WP(w,refit_d).sel = -1; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
155 |
} |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
156 |
|
0 | 157 |
static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) |
158 |
{ |
|
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
159 |
switch (e->event) { |
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
160 |
case WE_PAINT: { |
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
161 |
const Vehicle *v = GetVehicle(w->window_number); |
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
162 |
StringID str; |
0 | 163 |
|
164 |
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2); |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
165 |
// disable service-scroller when interval is set to disabled |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
166 |
if (!_patches.servint_roadveh) w->disabled_state |= (1 << 5) | (1 << 6); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
167 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
168 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
169 |
SetDParam(1, v->unitnumber); |
0 | 170 |
DrawWindowWidgets(w); |
171 |
||
172 |
/* Draw running cost */ |
|
173 |
{ |
|
174 |
int year = v->age / 366; |
|
175 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
176 |
SetDParam(1, year); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
177 |
|
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
178 |
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
179 |
SetDParam(2, v->max_age / 366); |
538
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
534
diff
changeset
|
180 |
SetDParam(3, RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running >> 8); |
0 | 181 |
DrawString(2, 15, STR_900D_AGE_RUNNING_COST_YR, 0); |
182 |
} |
|
183 |
||
184 |
/* Draw max speed */ |
|
185 |
{ |
|
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3431
diff
changeset
|
186 |
SetDParam(0, v->max_speed / 2); |
0 | 187 |
DrawString(2, 25, STR_900E_MAX_SPEED, 0); |
188 |
} |
|
189 |
||
190 |
/* Draw profit */ |
|
191 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
192 |
SetDParam(0, v->profit_this_year); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
193 |
SetDParam(1, v->profit_last_year); |
0 | 194 |
DrawString(2, 35, STR_900F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
195 |
} |
|
196 |
||
197 |
/* Draw breakdown & reliability */ |
|
198 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
199 |
SetDParam(0, v->reliability * 100 >> 16); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
200 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 201 |
DrawString(2, 45, STR_9010_RELIABILITY_BREAKDOWNS, 0); |
202 |
} |
|
203 |
||
204 |
/* Draw service interval text */ |
|
205 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
206 |
SetDParam(0, v->service_interval); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
207 |
SetDParam(1, v->date_of_last_service); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
208 |
DrawString(13, 90, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 209 |
} |
210 |
||
211 |
DrawRoadVehImage(v, 3, 57, INVALID_VEHICLE); |
|
212 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
213 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
214 |
SetDParam(1, 1920 + v->build_year); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
215 |
SetDParam(2, v->value); |
0 | 216 |
DrawString(34, 57, STR_9011_BUILT_VALUE, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
217 |
|
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1986
diff
changeset
|
218 |
SetDParam(0, _cargoc.names_long[v->cargo_type]); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
219 |
SetDParam(1, v->cargo_cap); |
0 | 220 |
DrawString(34, 67, STR_9012_CAPACITY, 0); |
221 |
||
222 |
str = STR_8812_EMPTY; |
|
223 |
if (v->cargo_count != 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
224 |
SetDParam(0, v->cargo_type); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
225 |
SetDParam(1, v->cargo_count); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
226 |
SetDParam(2, v->cargo_source); |
0 | 227 |
str = STR_8813_FROM; |
228 |
} |
|
229 |
DrawString(34, 78, str, 0); |
|
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
230 |
} break; |
0 | 231 |
|
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
232 |
case WE_CLICK: { |
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
233 |
int mod; |
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
234 |
const Vehicle *v; |
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
235 |
switch (e->click.widget) { |
0 | 236 |
case 2: /* rename */ |
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
237 |
v = GetVehicle(w->window_number); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
238 |
SetDParam(0, v->unitnumber); |
0 | 239 |
ShowQueryString(v->string_id, STR_902C_NAME_ROAD_VEHICLE, 31, 150, w->window_class, w->window_number); |
240 |
break; |
|
241 |
||
242 |
case 5: /* increase int */ |
|
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
243 |
mod = _ctrl_pressed? 5 : 10; |
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
244 |
goto do_change_service_int; |
0 | 245 |
case 6: /* decrease int */ |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
246 |
mod = _ctrl_pressed? -5 : -10; |
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
247 |
do_change_service_int: |
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
248 |
v = GetVehicle(w->window_number); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
249 |
|
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
250 |
mod = GetServiceIntervalClamped(mod + v->service_interval); |
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
251 |
if (mod == v->service_interval) return; |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
252 |
|
2819
f25fb6ee397f
(svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
tron
parents:
2806
diff
changeset
|
253 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
0 | 254 |
break; |
255 |
} |
|
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
256 |
} break; |
0 | 257 |
|
258 |
case WE_ON_EDIT_TEXT: { |
|
1820
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
259 |
if (e->edittext.str[0] != '\0') { |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
260 |
_cmd_text = e->edittext.str; |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
261 |
DoCommandP(0, w->window_number, 0, NULL, |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
262 |
CMD_NAME_VEHICLE | CMD_MSG(STR_902D_CAN_T_NAME_ROAD_VEHICLE)); |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
263 |
} |
0 | 264 |
} break; |
265 |
||
266 |
} |
|
267 |
} |
|
268 |
||
269 |
static const Widget _roadveh_details_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
270 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
271 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 339, 0, 13, STR_900C_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
272 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 340, 379, 0, 13, STR_01AA_NAME, STR_902E_NAME_ROAD_VEHICLE}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
273 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 379, 14, 55, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
274 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 379, 56, 88, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
275 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 89, 94, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
276 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 95, 100, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
277 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 11, 379, 89, 100, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
278 |
{ WIDGETS_END}, |
0 | 279 |
}; |
280 |
||
281 |
static const WindowDesc _roadveh_details_desc = { |
|
282 |
-1,-1, 380, 101, |
|
283 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
284 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
285 |
_roadveh_details_widgets, |
|
286 |
RoadVehDetailsWndProc |
|
287 |
}; |
|
288 |
||
4171 | 289 |
static void ShowRoadVehDetailsWindow(const Vehicle *v) |
0 | 290 |
{ |
291 |
Window *w; |
|
292 |
VehicleID veh = v->index; |
|
2639 | 293 |
|
0 | 294 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
295 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
296 |
_alloc_wnd_parent_num = veh; |
0 | 297 |
w = AllocateWindowDesc(&_roadveh_details_desc); |
298 |
w->window_number = veh; |
|
299 |
w->caption_color = v->owner; |
|
300 |
} |
|
301 |
||
3887
ece644bbf459
(svn r4943) uint tile -> TileIndex tile, byte player -> PlayerID player
tron
parents:
3884
diff
changeset
|
302 |
void CcCloneRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2) |
2244 | 303 |
{ |
3948
a09379beffd5
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3887
diff
changeset
|
304 |
if (success) ShowRoadVehViewWindow(GetVehicle(_new_vehicle_id)); |
2244 | 305 |
} |
306 |
||
0 | 307 |
static void RoadVehViewWndProc(Window *w, WindowEvent *e) |
308 |
{ |
|
2952 | 309 |
switch (e->event) { |
0 | 310 |
case WE_PAINT: { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
311 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 312 |
StringID str; |
313 |
||
3990
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
314 |
w->disabled_state = (v->owner != _local_player) ? (1 << 8 | 1 << 7 | 1 << 12) : 0; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
315 |
|
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
316 |
/* Disable refit button if vehicle not refittable */ |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
317 |
if (_engine_info[v->engine_type].refit_mask == 0) SETBIT(w->disabled_state, 12); |
0 | 318 |
|
319 |
/* draw widgets & caption */ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
320 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
321 |
SetDParam(1, v->unitnumber); |
0 | 322 |
DrawWindowWidgets(w); |
323 |
||
324 |
if (v->u.road.crashed_ctr != 0) { |
|
325 |
str = STR_8863_CRASHED; |
|
326 |
} else if (v->breakdown_ctr == 1) { |
|
327 |
str = STR_885C_BROKEN_DOWN; |
|
328 |
} else if (v->vehstatus & VS_STOPPED) { |
|
329 |
str = STR_8861_STOPPED; |
|
330 |
} else { |
|
555
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
331 |
switch (v->current_order.type) { |
0 | 332 |
case OT_GOTO_STATION: { |
555
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
333 |
SetDParam(0, v->current_order.station); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3431
diff
changeset
|
334 |
SetDParam(1, v->cur_speed / 2); |
0 | 335 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
336 |
} break; |
|
337 |
||
338 |
case OT_GOTO_DEPOT: { |
|
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
339 |
Depot *depot = GetDepot(v->current_order.station); |
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
340 |
SetDParam(0, depot->town_index); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3431
diff
changeset
|
341 |
SetDParam(1, v->cur_speed / 2); |
0 | 342 |
str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed; |
343 |
} break; |
|
344 |
||
345 |
case OT_LOADING: |
|
346 |
case OT_LEAVESTATION: |
|
347 |
str = STR_882F_LOADING_UNLOADING; |
|
348 |
break; |
|
349 |
||
350 |
default: |
|
351 |
if (v->num_orders == 0) { |
|
352 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3431
diff
changeset
|
353 |
SetDParam(0, v->cur_speed / 2); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
354 |
} else { |
0 | 355 |
str = STR_EMPTY; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
356 |
} |
0 | 357 |
break; |
358 |
} |
|
359 |
} |
|
360 |
||
2103
a2b3106d33d5
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2084
diff
changeset
|
361 |
/* draw the flag plus orders */ |
2517
6e3832ddd0f6
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
362 |
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, 2, w->widget[5].top + 1); |
2113
be2f07df0dfa
(svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents:
2103
diff
changeset
|
363 |
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0); |
0 | 364 |
DrawWindowViewport(w); |
365 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
366 |
|
0 | 367 |
case WE_CLICK: { |
4171 | 368 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 369 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
370 |
switch (e->click.widget) { |
755
80091de50044
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
371 |
case 5: /* start stop */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
372 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
0 | 373 |
break; |
755
80091de50044
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
374 |
case 6: /* center main view */ |
0 | 375 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
376 |
break; |
|
3990
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
377 |
case 7: /* goto depot */ |
0 | 378 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT)); |
379 |
break; |
|
755
80091de50044
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
380 |
case 8: /* turn around */ |
0 | 381 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); |
382 |
break; |
|
755
80091de50044
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
383 |
case 9: /* show orders */ |
0 | 384 |
ShowOrdersWindow(v); |
385 |
break; |
|
755
80091de50044
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
386 |
case 10: /* show details */ |
0 | 387 |
ShowRoadVehDetailsWindow(v); |
388 |
break; |
|
3990
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
389 |
case 11: /* clone vehicle */ |
2244 | 390 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneRoadVeh, CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE)); |
3990
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
391 |
break; |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
392 |
case 12: /* Refit vehicle */ |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
393 |
ShowRoadVehRefitWindow(v); |
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
394 |
break; |
0 | 395 |
} |
396 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
397 |
|
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
398 |
case WE_RESIZE: |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
399 |
w->viewport->width += e->sizing.diff.x; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
400 |
w->viewport->height += e->sizing.diff.y; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
401 |
w->viewport->virtual_width += e->sizing.diff.x; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
402 |
w->viewport->virtual_height += e->sizing.diff.y; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
403 |
break; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
404 |
|
0 | 405 |
case WE_DESTROY: |
3990
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
406 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
0 | 407 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
408 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
409 |
break; |
2244 | 410 |
|
411 |
case WE_MOUSELOOP: |
|
412 |
{ |
|
4171 | 413 |
const Vehicle *v = GetVehicle(w->window_number); |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3990
diff
changeset
|
414 |
uint32 h = IsRoadVehInDepotStopped(v) ? 1 << 7 | 1 << 8 : 1 << 11 | 1 << 12; |
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3990
diff
changeset
|
415 |
|
2244 | 416 |
if (h != w->hidden_state) { |
417 |
w->hidden_state = h; |
|
418 |
SetWindowDirty(w); |
|
419 |
} |
|
420 |
} |
|
0 | 421 |
} |
422 |
} |
|
423 |
||
424 |
static const Widget _roadveh_view_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
425 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
426 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_9002, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
427 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
428 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 231, 14, 103, 0x0, STR_NULL }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
429 |
{ WWT_6, RESIZE_RB, 14, 2, 229, 16, 101, 0x0, STR_NULL }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
430 |
{ WWT_PUSHIMGBTN, RESIZE_RTB, 14, 0, 237, 104, 115, 0x0, STR_901C_CURRENT_VEHICLE_ACTION }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
431 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, 0x2AB, STR_901E_CENTER_MAIN_VIEW_ON_VEHICLE }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
432 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2AE, STR_901F_SEND_VEHICLE_TO_DEPOT }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
433 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2CB, STR_9020_FORCE_VEHICLE_TO_TURN_AROUND }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
434 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B2, STR_901D_SHOW_VEHICLE_S_ORDERS }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
435 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B3, STR_9021_SHOW_ROAD_VEHICLE_DETAILS }, |
2244 | 436 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_ROADVEH, STR_CLONE_ROAD_VEHICLE_INFO }, |
3990
a317e665fb77
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3960
diff
changeset
|
437 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2B4, STR_REFIT_ROAD_VEHICLE_TO_CARRY }, |
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
438 |
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
439 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
440 |
{ WIDGETS_END } |
0 | 441 |
}; |
442 |
||
443 |
static const WindowDesc _roadveh_view_desc = { |
|
444 |
-1,-1, 250, 116, |
|
445 |
WC_VEHICLE_VIEW,0, |
|
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
446 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 447 |
_roadveh_view_widgets, |
448 |
RoadVehViewWndProc, |
|
449 |
}; |
|
450 |
||
4171 | 451 |
void ShowRoadVehViewWindow(const Vehicle *v) |
0 | 452 |
{ |
4171 | 453 |
Window *w = AllocateWindowDescFront(&_roadveh_view_desc, v->index); |
0 | 454 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
455 |
if (w != NULL) { |
0 | 456 |
w->caption_color = v->owner; |
457 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
458 |
} |
|
459 |
} |
|
460 |
||
461 |
||
462 |
static void DrawNewRoadVehWindow(Window *w) |
|
463 |
{ |
|
464 |
if (w->window_number == 0) |
|
465 |
w->disabled_state = 1 << 5; |
|
466 |
||
467 |
// setup scroller |
|
468 |
{ |
|
469 |
int count = 0; |
|
470 |
int num = NUM_ROAD_ENGINES; |
|
4171 | 471 |
const Engine *e = GetEngine(ROAD_ENGINES_INDEX); |
1926
530480d14685
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
472 |
|
0 | 473 |
do { |
474 |
if (HASBIT(e->player_avail, _local_player)) |
|
475 |
count++; |
|
476 |
} while (++e,--num); |
|
477 |
SetVScrollCount(w, count); |
|
478 |
} |
|
479 |
||
480 |
DrawWindowWidgets(w); |
|
481 |
||
482 |
{ |
|
483 |
int num = NUM_ROAD_ENGINES; |
|
4171 | 484 |
const Engine *e = GetEngine(ROAD_ENGINES_INDEX); |
0 | 485 |
int x = 1; |
486 |
int y = 15; |
|
487 |
int sel = WP(w,buildtrain_d).sel_index; |
|
488 |
int pos = w->vscroll.pos; |
|
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2466
diff
changeset
|
489 |
EngineID engine_id = ROAD_ENGINES_INDEX; |
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
490 |
EngineID selected_id = INVALID_ENGINE; |
0 | 491 |
|
492 |
do { |
|
493 |
if (HASBIT(e->player_avail, _local_player)) { |
|
494 |
if (sel==0) selected_id = engine_id; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
495 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
0 | 496 |
DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); |
3040
7043c0de7c6d
(svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents:
2962
diff
changeset
|
497 |
DrawRoadVehEngine(x+29, y+6, engine_id, GetEnginePalette(engine_id, _local_player)); |
0 | 498 |
y += 14; |
499 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
500 |
sel--; |
0 | 501 |
} |
502 |
} while (++engine_id, ++e,--num); |
|
503 |
||
504 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
505 |
if (selected_id != INVALID_ENGINE) { |
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
506 |
DrawRoadVehPurchaseInfo(2, w->widget[4].top + 1, selected_id); |
0 | 507 |
} |
508 |
} |
|
509 |
} |
|
510 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
511 |
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 512 |
{ |
4171 | 513 |
const Vehicle *v; |
0 | 514 |
|
515 |
if (!success) return; |
|
516 |
||
3948
a09379beffd5
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3887
diff
changeset
|
517 |
v = GetVehicle(_new_vehicle_id); |
0 | 518 |
if (v->tile == _backup_orders_tile) { |
519 |
_backup_orders_tile = 0; |
|
520 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
521 |
} |
|
522 |
ShowRoadVehViewWindow(v); |
|
523 |
} |
|
524 |
||
525 |
static void NewRoadVehWndProc(Window *w, WindowEvent *e) |
|
526 |
{ |
|
2639 | 527 |
switch (e->event) { |
0 | 528 |
case WE_PAINT: |
529 |
DrawNewRoadVehWindow(w); |
|
530 |
break; |
|
531 |
||
532 |
case WE_CLICK: |
|
2952 | 533 |
switch (e->click.widget) { |
0 | 534 |
case 2: { /* listbox */ |
535 |
uint i = (e->click.pt.y - 14) / 14; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
536 |
if (i < w->vscroll.cap) { |
0 | 537 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
538 |
SetWindowDirty(w); |
|
539 |
} |
|
540 |
} break; |
|
541 |
||
542 |
case 5: { /* build */ |
|
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
543 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
544 |
if (sel_eng != INVALID_ENGINE) |
0 | 545 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE)); |
546 |
} break; |
|
547 |
||
968
84a870c7a585
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
548 |
case 6: { /* rename */ |
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
549 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
550 |
if (sel_eng != INVALID_ENGINE) { |
968
84a870c7a585
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
551 |
WP(w,buildtrain_d).rename_engine = sel_eng; |
84a870c7a585
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
552 |
ShowQueryString(GetCustomEngineName(sel_eng), |
84a870c7a585
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
553 |
STR_9036_RENAME_ROAD_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number); |
84a870c7a585
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
554 |
} |
84a870c7a585
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
555 |
} break; |
0 | 556 |
} |
557 |
break; |
|
558 |
||
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
559 |
case WE_ON_EDIT_TEXT: |
1820
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
560 |
if (e->edittext.str[0] != '\0') { |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
561 |
_cmd_text = e->edittext.str; |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
562 |
DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
563 |
CMD_RENAME_ENGINE | CMD_MSG(STR_9037_CAN_T_RENAME_ROAD_VEHICLE)); |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
564 |
} |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
565 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
566 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
567 |
case WE_RESIZE: { |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
568 |
if (e->sizing.diff.y == 0) break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
569 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
570 |
w->vscroll.cap += e->sizing.diff.y / 14; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
571 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
572 |
} break; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
573 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
574 |
} |
0 | 575 |
} |
576 |
||
577 |
static const Widget _new_road_veh_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
578 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
579 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 247, 0, 13, STR_9006_NEW_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
580 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 235, 14, 125, 0x801, STR_9026_ROAD_VEHICLE_SELECTION}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
581 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 236, 247, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
582 |
{ WWT_IMGBTN, RESIZE_TB, 14, 0, 247, 126, 177, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
583 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 117, 178, 189, STR_9007_BUILD_VEHICLE,STR_9027_BUILD_THE_HIGHLIGHTED_ROAD}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
584 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 118, 235, 178, 189, STR_9034_RENAME, STR_9035_RENAME_ROAD_VEHICLE_TYPE}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
585 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 236, 247, 178, 189, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
586 |
{ WIDGETS_END}, |
0 | 587 |
}; |
588 |
||
589 |
static const WindowDesc _new_road_veh_desc = { |
|
590 |
-1, -1, 248, 190, |
|
591 |
WC_BUILD_VEHICLE,0, |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
592 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 593 |
_new_road_veh_widgets, |
594 |
NewRoadVehWndProc |
|
595 |
}; |
|
596 |
||
597 |
static void ShowBuildRoadVehWindow(TileIndex tile) |
|
598 |
{ |
|
599 |
Window *w; |
|
600 |
||
601 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
602 |
||
603 |
w = AllocateWindowDesc(&_new_road_veh_desc); |
|
604 |
w->window_number = tile; |
|
605 |
w->vscroll.cap = 8; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
606 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
607 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
608 |
w->resize.step_height = 14; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
609 |
w->resize.height = w->height - 14 * 4; /* Minimum of 4 vehicles in the display */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
610 |
|
0 | 611 |
if (tile != 0) { |
1901
03bf9bf99319
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
612 |
w->caption_color = GetTileOwner(tile); |
0 | 613 |
} else { |
614 |
w->caption_color = _local_player; |
|
615 |
} |
|
616 |
} |
|
617 |
||
618 |
static void DrawRoadDepotWindow(Window *w) |
|
619 |
{ |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
620 |
TileIndex tile; |
0 | 621 |
Vehicle *v; |
622 |
int num,x,y; |
|
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
623 |
Depot *depot; |
0 | 624 |
|
625 |
tile = w->window_number; |
|
626 |
||
627 |
/* setup disabled buttons */ |
|
1901
03bf9bf99319
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
628 |
w->disabled_state = |
2244 | 629 |
IsTileOwner(tile, _local_player) ? 0 : ((1<<4) | (1<<7) | (1<<8)); |
0 | 630 |
|
631 |
/* determine amount of items for scroller */ |
|
632 |
num = 0; |
|
633 |
FOR_ALL_VEHICLES(v) { |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
634 |
if (v->type == VEH_Road && IsRoadVehInDepot(v) && v->tile == tile) num++; |
0 | 635 |
} |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
636 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
0 | 637 |
|
638 |
/* locate the depot struct */ |
|
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
639 |
depot = GetDepotByTile(tile); |
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
640 |
assert(depot != NULL); |
0 | 641 |
|
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
642 |
SetDParam(0, depot->town_index); |
0 | 643 |
DrawWindowWidgets(w); |
644 |
||
645 |
x = 2; |
|
646 |
y = 15; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
647 |
num = w->vscroll.pos * w->hscroll.cap; |
0 | 648 |
|
649 |
FOR_ALL_VEHICLES(v) { |
|
3959 | 650 |
if (v->type == VEH_Road && IsRoadVehInDepot(v) && v->tile == tile && |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
651 |
--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) { |
0 | 652 |
DrawRoadVehImage(v, x+24, y, WP(w,traindepot_d).sel); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
653 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
654 |
SetDParam(0, v->unitnumber); |
0 | 655 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
656 |
||
2517
6e3832ddd0f6
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
657 |
DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x + 16, y); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
658 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
659 |
if ((x+=56) == 2 + 56 * w->hscroll.cap) { |
0 | 660 |
x = 2; |
661 |
y += 14; |
|
662 |
} |
|
663 |
} |
|
664 |
} |
|
665 |
} |
|
666 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
667 |
static int GetVehicleFromRoadDepotWndPt(const Window *w, int x, int y, Vehicle **veh) |
0 | 668 |
{ |
969
862685f513ca
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
669 |
uint xt,row,xm; |
0 | 670 |
TileIndex tile; |
671 |
Vehicle *v; |
|
672 |
int pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
673 |
|
0 | 674 |
xt = x / 56; |
675 |
xm = x % 56; |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
676 |
if (xt >= w->hscroll.cap) return 1; |
0 | 677 |
|
969
862685f513ca
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
678 |
row = (y - 14) / 14; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
679 |
if (row >= w->vscroll.cap) return 1; |
0 | 680 |
|
971
374251680a61
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
681 |
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt; |
0 | 682 |
|
683 |
tile = w->window_number; |
|
684 |
FOR_ALL_VEHICLES(v) { |
|
3959 | 685 |
if (v->type == VEH_Road && IsRoadVehInDepot(v) && v->tile == tile && |
0 | 686 |
--pos < 0) { |
1986
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
687 |
*veh = v; |
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
688 |
if (xm >= 24) return 0; |
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
689 |
if (xm <= 16) return -1; /* show window */ |
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
690 |
return -2; /* start stop */ |
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
691 |
} |
0 | 692 |
} |
693 |
||
694 |
return 1; /* outside */ |
|
695 |
} |
|
696 |
||
697 |
static void RoadDepotClickVeh(Window *w, int x, int y) |
|
698 |
{ |
|
699 |
Vehicle *v; |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
700 |
int mode; |
0 | 701 |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
702 |
mode = GetVehicleFromRoadDepotWndPt(w, x, y, &v); |
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
703 |
if (mode > 0) return; |
0 | 704 |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
705 |
// share / copy orders |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
706 |
if (_thd.place_mode && mode <= 0) { |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
707 |
_place_clicked_vehicle = v; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
708 |
return; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
709 |
} |
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
710 |
|
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
711 |
switch (mode) { |
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
712 |
case 0: // start dragging of vehicle |
0 | 713 |
if (v != NULL) { |
714 |
WP(w,traindepot_d).sel = v->index; |
|
715 |
SetWindowDirty(w); |
|
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3049
diff
changeset
|
716 |
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetRoadVehImage(v, DIR_W), 4, w); |
0 | 717 |
} |
718 |
break; |
|
719 |
||
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
720 |
case -1: // show info window |
0 | 721 |
ShowRoadVehViewWindow(v); |
722 |
break; |
|
723 |
||
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
724 |
case -2: // click start/stop flag |
0 | 725 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
726 |
break; |
|
727 |
||
728 |
default: |
|
729 |
NOT_REACHED(); |
|
730 |
} |
|
731 |
} |
|
732 |
||
2244 | 733 |
/** |
734 |
* Clones a road vehicle |
|
735 |
* @param *v is the original vehicle to clone |
|
736 |
* @param *w is the window of the depot where the clone is build |
|
737 |
*/ |
|
4171 | 738 |
static void HandleCloneVehClick(const Vehicle *v, const Window *w) |
2244 | 739 |
{ |
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
740 |
if (v == NULL || v->type != VEH_Road) return; |
2244 | 741 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
742 |
DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneRoadVeh, |
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
743 |
CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE) |
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
744 |
); |
2244 | 745 |
|
746 |
ResetObjectToPlace(); |
|
747 |
} |
|
748 |
||
4171 | 749 |
static void ClonePlaceObj(const Window *w) |
2244 | 750 |
{ |
4171 | 751 |
const Vehicle *v = CheckMouseOverVehicle(); |
2244 | 752 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
753 |
if (v != NULL) HandleCloneVehClick(v, w); |
2244 | 754 |
} |
755 |
||
0 | 756 |
static void RoadDepotWndProc(Window *w, WindowEvent *e) |
757 |
{ |
|
2952 | 758 |
switch (e->event) { |
0 | 759 |
case WE_PAINT: |
760 |
DrawRoadDepotWindow(w); |
|
761 |
break; |
|
762 |
||
763 |
case WE_CLICK: { |
|
2952 | 764 |
switch (e->click.widget) { |
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
765 |
case 5: |
0 | 766 |
RoadDepotClickVeh(w, e->click.pt.x, e->click.pt.y); |
767 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
768 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
769 |
case 7: |
2244 | 770 |
ResetObjectToPlace(); |
0 | 771 |
ShowBuildRoadVehWindow(w->window_number); |
772 |
break; |
|
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
773 |
|
2244 | 774 |
case 8: /* clone button */ |
775 |
InvalidateWidget(w, 8); |
|
776 |
TOGGLEBIT(w->click_state, 8); |
|
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
777 |
|
2244 | 778 |
if (HASBIT(w->click_state, 8)) { |
779 |
_place_clicked_vehicle = NULL; |
|
780 |
SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w); |
|
781 |
} else { |
|
782 |
ResetObjectToPlace(); |
|
783 |
} |
|
784 |
break; |
|
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
785 |
|
2244 | 786 |
case 9: /* scroll to tile */ |
787 |
ResetObjectToPlace(); |
|
788 |
ScrollMainWindowToTile(w->window_number); |
|
789 |
break; |
|
790 |
} |
|
791 |
} break; |
|
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
792 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
793 |
case WE_PLACE_OBJ: |
2958
ac0a9673b522
(svn r3520) Remove unused parameters from some functions
tron
parents:
2952
diff
changeset
|
794 |
ClonePlaceObj(w); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
795 |
break; |
0 | 796 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
797 |
case WE_ABORT_PLACE_OBJ: |
2244 | 798 |
CLRBIT(w->click_state, 8); |
799 |
InvalidateWidget(w, 8); |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
800 |
break; |
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
801 |
|
2244 | 802 |
// check if a vehicle in a depot was clicked.. |
803 |
case WE_MOUSELOOP: { |
|
4171 | 804 |
const Vehicle *v = _place_clicked_vehicle; |
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
805 |
|
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
806 |
// since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button |
2244 | 807 |
if (v != NULL && HASBIT(w->click_state, 8)) { |
808 |
_place_clicked_vehicle = NULL; |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
809 |
HandleCloneVehClick(v, w); |
0 | 810 |
} |
811 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
812 |
|
0 | 813 |
case WE_DESTROY: |
814 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
815 |
break; |
|
816 |
||
2755
ba133949851b
(svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents:
2725
diff
changeset
|
817 |
case WE_DRAGDROP: |
2952 | 818 |
switch (e->click.widget) { |
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
819 |
case 5: { |
0 | 820 |
Vehicle *v; |
821 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
822 |
||
823 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
824 |
SetWindowDirty(w); |
|
825 |
||
826 |
if (GetVehicleFromRoadDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
827 |
v != NULL && |
|
828 |
sel == v->index) { |
|
829 |
ShowRoadVehViewWindow(v); |
|
830 |
} |
|
831 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
832 |
|
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
833 |
case 4: |
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
834 |
if (!HASBIT(w->disabled_state, 4) && |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
835 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
0 | 836 |
Vehicle *v; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
837 |
|
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
838 |
HandleButtonClick(w, 4); |
0 | 839 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
840 |
v = GetVehicle(WP(w,traindepot_d).sel); |
0 | 841 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
842 |
||
843 |
_backup_orders_tile = v->tile; |
|
844 |
BackupVehicleOrders(v, _backup_orders_data); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
845 |
|
0 | 846 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE))) |
847 |
_backup_orders_tile = 0; |
|
848 |
} |
|
849 |
break; |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
850 |
|
0 | 851 |
default: |
852 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
853 |
SetWindowDirty(w); |
|
854 |
} |
|
855 |
break; |
|
856 |
||
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
857 |
case WE_RESIZE: |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
858 |
/* Update the scroll + matrix */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
859 |
w->vscroll.cap += e->sizing.diff.y / 14; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
860 |
w->hscroll.cap += e->sizing.diff.x / 56; |
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
861 |
w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
862 |
break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
863 |
|
0 | 864 |
} |
865 |
} |
|
866 |
||
867 |
static const Widget _road_depot_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
868 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
869 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 302, 0, 13, STR_9003_ROAD_VEHICLE_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
870 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 303, 314, 0, 13, 0x0, STR_STICKY_BUTTON}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
871 |
{ WWT_PANEL, RESIZE_LRB, 14, 280, 302, 14, 13, 0x0, STR_NULL}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
872 |
{ WWT_IMGBTN, RESIZE_LRTB, 14, 280, 302, 14, 55, 0x2A9, STR_9024_DRAG_ROAD_VEHICLE_TO_HERE}, |
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
873 |
|
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
874 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 279, 14, 55, 0x305, STR_9022_VEHICLES_CLICK_ON_VEHICLE}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
875 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 303, 314, 14, 55, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
2244 | 876 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 100, 56, 67, STR_9004_NEW_VEHICLES, STR_9023_BUILD_NEW_ROAD_VEHICLE}, |
877 |
{WWT_NODISTXTBTN, RESIZE_TB, 14, 101, 200, 56, 67, STR_CLONE_ROAD_VEHICLE, STR_CLONE_ROAD_VEHICLE_DEPOT_INFO}, |
|
878 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 201, 302, 56, 67, STR_00E4_LOCATION, STR_9025_CENTER_MAIN_VIEW_ON_ROAD}, |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
879 |
{ WWT_PANEL, RESIZE_RTB, 14, 303, 302, 56, 67, 0x0, STR_NULL}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
880 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 303, 314, 56, 67, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
881 |
{ WIDGETS_END}, |
0 | 882 |
}; |
883 |
||
884 |
static const WindowDesc _road_depot_desc = { |
|
885 |
-1, -1, 315, 68, |
|
886 |
WC_VEHICLE_DEPOT,0, |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
887 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 888 |
_road_depot_widgets, |
889 |
RoadDepotWndProc |
|
890 |
}; |
|
891 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
892 |
void ShowRoadDepotWindow(TileIndex tile) |
0 | 893 |
{ |
4171 | 894 |
Window *w = AllocateWindowDescFront(&_road_depot_desc, tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
895 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
896 |
if (w != NULL) { |
1901
03bf9bf99319
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
897 |
w->caption_color = GetTileOwner(w->window_number); |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
898 |
w->hscroll.cap = 5; |
0 | 899 |
w->vscroll.cap = 3; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
900 |
w->resize.step_width = 56; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
901 |
w->resize.step_height = 14; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
902 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
0 | 903 |
_backup_orders_tile = 0; |
904 |
} |
|
905 |
} |
|
906 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
907 |
static const Widget _player_roadveh_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
908 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
909 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
910 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
2806
74949f22099e
(svn r3354) Fix a typo, which survived for about 3000 revisions: s/SRT_SORT_BY/STR_SORT_BY/ (noticed by chu)
tron
parents:
2755
diff
changeset
|
911 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
912 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
913 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
914 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
915 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
916 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
588 | 917 |
/* only for our road list, a 'Build Vehicle' button that opens the depot of the last built depot */ |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
918 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 208, 219, STR_8815_NEW_VEHICLES, STR_901B_BUILD_NEW_ROAD_VEHICLES}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
919 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 208, 219, STR_REPLACE_VEHICLES, STR_REPLACE_HELP}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
920 |
{ WWT_PANEL, RESIZE_RTB, 14, 248, 247, 208, 219, 0x0, STR_NULL}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
921 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 922 |
{ WIDGETS_END}, |
923 |
}; |
|
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:
156
diff
changeset
|
924 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
925 |
static const Widget _other_player_roadveh_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
926 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
927 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
928 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
2806
74949f22099e
(svn r3354) Fix a typo, which survived for about 3000 revisions: s/SRT_SORT_BY/STR_SORT_BY/ (noticed by chu)
tron
parents:
2755
diff
changeset
|
929 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
930 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
931 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
932 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
933 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
934 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
935 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 208, 219, 0x0, STR_NULL}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
936 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 937 |
{ WIDGETS_END}, |
938 |
}; |
|
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:
156
diff
changeset
|
939 |
|
0 | 940 |
static void PlayerRoadVehWndProc(Window *w, WindowEvent *e) |
941 |
{ |
|
2466
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
942 |
StationID station = GB(w->window_number, 16, 16); |
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
943 |
PlayerID owner = GB(w->window_number, 0, 8); |
588 | 944 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
945 |
||
2952 | 946 |
switch (e->event) { |
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:
156
diff
changeset
|
947 |
case WE_PAINT: { |
588 | 948 |
int x = 2; |
949 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
950 |
int max; |
|
951 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
952 |
|
588 | 953 |
BuildVehicleList(vl, VEH_Road, owner, station); |
954 |
SortVehicleList(vl); |
|
0 | 955 |
|
588 | 956 |
SetVScrollCount(w, vl->list_length); |
957 |
||
958 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
959 |
if (vl->sort_type == SORT_BY_UNSORTED) w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
960 |
|
0 | 961 |
/* draw the widgets */ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
962 |
if (station == INVALID_STATION) { |
4171 | 963 |
const Player *p = GetPlayer(owner); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
964 |
|
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
965 |
/* Company Name -- (###) Road vehicles */ |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
966 |
SetDParam(0, p->name_1); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
967 |
SetDParam(1, p->name_2); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
968 |
SetDParam(2, w->vscroll.count); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
969 |
w->widget[1].unkA = STR_9001_ROAD_VEHICLES; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
970 |
} else { |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
971 |
/* Station Name -- (###) Road vehicles */ |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
972 |
SetDParam(0, station); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
973 |
SetDParam(1, w->vscroll.count); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
974 |
w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES; |
0 | 975 |
} |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
976 |
DrawWindowWidgets(w); |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
977 |
/* draw sorting criteria string */ |
588 | 978 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
979 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
2406
8c873205483a
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2273
diff
changeset
|
980 |
DoDrawString(vl->flags & VL_DESC ? DOWNARROW : UPARROW, 69, 15, 0x10); |
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:
156
diff
changeset
|
981 |
|
588 | 982 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
983 |
for (i = w->vscroll.pos; i < max; ++i) { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
984 |
Vehicle *v = GetVehicle(vl->sort_list[i].index); |
588 | 985 |
StringID str; |
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:
156
diff
changeset
|
986 |
|
588 | 987 |
assert(v->type == VEH_Road && v->owner == owner); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
988 |
|
588 | 989 |
DrawRoadVehImage(v, x + 22, y + 6, INVALID_VEHICLE); |
990 |
DrawVehicleProfitButton(v, x, y + 13); |
|
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:
156
diff
changeset
|
991 |
|
588 | 992 |
SetDParam(0, v->unitnumber); |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3990
diff
changeset
|
993 |
if (IsRoadVehInDepot(v)) { |
588 | 994 |
str = STR_021F; |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3990
diff
changeset
|
995 |
} else { |
588 | 996 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3990
diff
changeset
|
997 |
} |
588 | 998 |
DrawString(x, y + 2, str, 0); |
999 |
||
1000 |
SetDParam(0, v->profit_this_year); |
|
1001 |
SetDParam(1, v->profit_last_year); |
|
1002 |
DrawString(x + 24, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1003 |
||
671
6f1d8c908156
(svn r1109) Fix c&p bug: In vehicle lists a name was displayed for road vehicles even if they had none
tron
parents:
588
diff
changeset
|
1004 |
if (v->string_id != STR_SV_ROADVEH_NAME) { |
588 | 1005 |
SetDParam(0, v->string_id); |
1006 |
DrawString(x + 24, y, STR_01AB, 0); |
|
0 | 1007 |
} |
588 | 1008 |
|
1009 |
y += PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
|
0 | 1010 |
} |
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:
156
diff
changeset
|
1011 |
} break; |
0 | 1012 |
|
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:
156
diff
changeset
|
1013 |
case WE_CLICK: { |
2952 | 1014 |
switch (e->click.widget) { |
757 | 1015 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 1016 |
vl->flags ^= VL_DESC; |
1017 |
vl->flags |= VL_RESORT; |
|
1246
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1151
diff
changeset
|
1018 |
_sorting.roadveh.order = !!(vl->flags & VL_DESC); |
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:
156
diff
changeset
|
1019 |
SetWindowDirty(w); |
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:
156
diff
changeset
|
1020 |
break; |
588 | 1021 |
|
757 | 1022 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 1023 |
ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0); |
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:
156
diff
changeset
|
1024 |
return; |
757 | 1025 |
case 7: { /* Matrix to show vehicles */ |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
1026 |
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
4171 | 1027 |
const Vehicle *v; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1028 |
|
2549 | 1029 |
if (id_v >= w->vscroll.cap) return; // click out of bounds |
0 | 1030 |
|
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:
156
diff
changeset
|
1031 |
id_v += w->vscroll.pos; |
0 | 1032 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1033 |
if (id_v >= vl->list_length) return; // click out of list bound |
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:
156
diff
changeset
|
1034 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1035 |
v = GetVehicle(vl->sort_list[id_v].index); |
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:
156
diff
changeset
|
1036 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1037 |
assert(v->type == VEH_Road && v->owner == owner); |
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:
156
diff
changeset
|
1038 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1039 |
ShowRoadVehViewWindow(v); |
0 | 1040 |
} break; |
1041 |
||
3884
793081f80381
(svn r4940) Remove the dubious feature of remembering the last built depot. It serves no real purpose except causing confusion
tron
parents:
3477
diff
changeset
|
1042 |
case 9: /* Build new Vehicle */ |
793081f80381
(svn r4940) Remove the dubious feature of remembering the last built depot. It serves no real purpose except causing confusion
tron
parents:
3477
diff
changeset
|
1043 |
if (!IsWindowOfPrototype(w, _player_roadveh_widgets)) break; |
793081f80381
(svn r4940) Remove the dubious feature of remembering the last built depot. It serves no real purpose except causing confusion
tron
parents:
3477
diff
changeset
|
1044 |
ShowBuildRoadVehWindow(0); |
793081f80381
(svn r4940) Remove the dubious feature of remembering the last built depot. It serves no real purpose except causing confusion
tron
parents:
3477
diff
changeset
|
1045 |
break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1046 |
|
842 | 1047 |
case 10: { |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1048 |
if (!IsWindowOfPrototype(w, _player_roadveh_widgets)) break; |
842 | 1049 |
ShowReplaceVehicleWindow(VEH_Road); |
1050 |
break; |
|
1051 |
} |
|
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:
156
diff
changeset
|
1052 |
} |
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:
156
diff
changeset
|
1053 |
} break; |
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:
156
diff
changeset
|
1054 |
|
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:
156
diff
changeset
|
1055 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 1056 |
if (vl->sort_type != e->dropdown.index) { |
1057 |
// value has changed -> resort |
|
1058 |
vl->flags |= VL_RESORT; |
|
1059 |
vl->sort_type = e->dropdown.index; |
|
1246
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1151
diff
changeset
|
1060 |
_sorting.roadveh.criteria = vl->sort_type; |
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:
156
diff
changeset
|
1061 |
|
588 | 1062 |
// enable 'Sort By' if a sorter criteria is chosen |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1063 |
if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3); |
588 | 1064 |
} |
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:
156
diff
changeset
|
1065 |
SetWindowDirty(w); |
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:
156
diff
changeset
|
1066 |
break; |
588 | 1067 |
|
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:
156
diff
changeset
|
1068 |
case WE_CREATE: /* set up resort timer */ |
588 | 1069 |
vl->sort_list = NULL; |
1246
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1151
diff
changeset
|
1070 |
vl->flags = VL_REBUILD | (_sorting.roadveh.order << (VL_DESC - 1)); |
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1151
diff
changeset
|
1071 |
vl->sort_type = _sorting.roadveh.criteria; |
588 | 1072 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
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:
156
diff
changeset
|
1073 |
break; |
588 | 1074 |
|
767 | 1075 |
case WE_DESTROY: |
1076 |
free(vl->sort_list); |
|
1077 |
break; |
|
1078 |
||
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:
156
diff
changeset
|
1079 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 1080 |
if (--vl->resort_timer == 0) { |
1081 |
DEBUG(misc, 1) ("Periodic resort road vehicles list player %d station %d", |
|
1082 |
owner, station); |
|
1083 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1084 |
vl->flags |= VL_RESORT; |
|
1085 |
SetWindowDirty(w); |
|
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:
156
diff
changeset
|
1086 |
} |
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:
156
diff
changeset
|
1087 |
break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1088 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1089 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1090 |
/* Update the scroll + matrix */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1091 |
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1092 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1093 |
break; |
0 | 1094 |
} |
1095 |
} |
|
1096 |
||
1097 |
static const WindowDesc _player_roadveh_desc = { |
|
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:
156
diff
changeset
|
1098 |
-1, -1, 260, 220, |
0 | 1099 |
WC_ROADVEH_LIST,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1100 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1101 |
_player_roadveh_widgets, |
1102 |
PlayerRoadVehWndProc |
|
1103 |
}; |
|
1104 |
||
1105 |
static const WindowDesc _other_player_roadveh_desc = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1106 |
-1, -1, 260, 220, |
0 | 1107 |
WC_ROADVEH_LIST,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1108 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1109 |
_other_player_roadveh_widgets, |
1110 |
PlayerRoadVehWndProc |
|
1111 |
}; |
|
1112 |
||
1113 |
||
2466
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1114 |
void ShowPlayerRoadVehicles(PlayerID player, StationID station) |
0 | 1115 |
{ |
1116 |
Window *w; |
|
1117 |
||
1118 |
if ( player == _local_player) { |
|
588 | 1119 |
w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | player); |
0 | 1120 |
} else { |
588 | 1121 |
w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | player); |
0 | 1122 |
} |
2639 | 1123 |
if (w != NULL) { |
0 | 1124 |
w->caption_color = player; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1125 |
w->vscroll.cap = 7; // maximum number of vehicles shown |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1126 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1127 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1128 |
w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */ |
0 | 1129 |
} |
1130 |
} |