Files
@ r556:6d4e803d1a75
Branch filter:
Location: cpp/openttd-patchpack/source/road_gui.c - annotation
r556:6d4e803d1a75
15.9 KiB
text/x-c
(svn r957) -Fix: vehicle.c compiler problems for MSVC6 only! (Tron)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | r0:d63b455452f6 r0:d63b455452f6 r507:b1b0a0a3c313 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r337:998f55d0b04c r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r5:283cc53559b4 r5:283cc53559b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r514:ea9196728592 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r176:7d9100f64c27 r0:d63b455452f6 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r176:7d9100f64c27 r0:d63b455452f6 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r176:7d9100f64c27 r0:d63b455452f6 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r176:7d9100f64c27 r0:d63b455452f6 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 | #include "stdafx.h"
#include "ttd.h"
#include "table/strings.h"
#include "window.h"
#include "gui.h"
#include "viewport.h"
#include "gfx.h"
#include "sound.h"
#include "command.h"
static void ShowBusStationPicker();
static void ShowTruckStationPicker();
static void ShowRoadDepotPicker();
static bool _remove_button_clicked;
static bool _build_road_flag;
static byte _place_road_flag;
static byte _road_depot_orientation;
static byte _road_station_picker_orientation;
void CcPlaySound1D(bool success, uint tile, uint32 p1, uint32 p2)
{
if (success) SndPlayTileFx(SND_1F_SPLAT, tile);
}
static void PlaceRoad_NE(uint tile)
{
_place_road_flag = (_tile_fract_coords.y >= 8) + 4;
VpStartPlaceSizing(tile, VPM_FIX_X);
}
static void PlaceRoad_NW(uint tile)
{
_place_road_flag = (_tile_fract_coords.x >= 8) + 0;
VpStartPlaceSizing(tile, VPM_FIX_Y);
}
static void PlaceRoad_Bridge(uint tile)
{
VpStartPlaceSizing(tile, VPM_X_OR_Y);
}
void CcBuildRoadTunnel(bool success, uint tile, uint32 p1, uint32 p2)
{
if (success) {
SndPlayTileFx(SND_20_SPLAT_2, tile);
ResetObjectToPlace();
} else {
SetRedErrorSquare(_build_tunnel_endtile);
}
}
static void PlaceRoad_Tunnel(uint tile)
{
DoCommandP(tile, 0x200, 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
}
static void BuildRoadOutsideStation(uint tile, int direction)
{
static const byte _roadbits_by_dir[4] = {2,1,8,4};
tile += _tileoffs_by_dir[direction];
// if there is a roadpiece just outside of the station entrance, build a connecting route
if (IS_TILETYPE(tile, MP_STREET) && !(_map5[tile]&0x20)) {
DoCommandP(tile, _roadbits_by_dir[direction], 0, NULL, CMD_BUILD_ROAD);
}
}
void CcRoadDepot(bool success, uint tile, uint32 p1, uint32 p2)
{
if (success) {
SndPlayTileFx(SND_1F_SPLAT, tile);
ResetObjectToPlace();
BuildRoadOutsideStation(tile, (int)p1);
}
}
static void PlaceRoad_Depot(uint tile)
{
DoCommandP(tile, _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1807_CAN_T_BUILD_ROAD_VEHICLE));
}
static void PlaceRoad_BusStation(uint tile)
{
DoCommandP(tile, _road_station_picker_orientation, 0, CcRoadDepot, CMD_BUILD_BUS_STATION | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1808_CAN_T_BUILD_BUS_STATION));
}
static void PlaceRoad_TruckStation(uint tile)
{
DoCommandP(tile, _road_station_picker_orientation, 0, CcRoadDepot, CMD_BUILD_TRUCK_STATION | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1809_CAN_T_BUILD_TRUCK_STATION));
}
static void PlaceRoad_DemolishArea(uint tile)
{
VpStartPlaceSizing(tile, 4);
}
typedef void OnButtonClick(Window *w);
static void BuildRoadClick_NE(Window *w)
{
_build_road_flag = 0;
HandlePlacePushButton(w, 2, 0x51F, 1, PlaceRoad_NE);
}
static void BuildRoadClick_NW(Window *w)
{
_build_road_flag = 0;
HandlePlacePushButton(w, 3, 0x520, 1, PlaceRoad_NW);
}
static void BuildRoadClick_Demolish(Window *w)
{
HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, 1, PlaceRoad_DemolishArea);
}
static void BuildRoadClick_Lower(Window *w)
{
HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerLand);
}
static void BuildRoadClick_Raise(Window *w)
{
HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseLand);
}
static void BuildRoadClick_Depot(Window *w)
{
if (HandlePlacePushButton(w, 7, 0x511, 1, PlaceRoad_Depot)) ShowRoadDepotPicker();
}
static void BuildRoadClick_BusStation(Window *w)
{
if (HandlePlacePushButton(w, 8, 0xAA5, 1, PlaceRoad_BusStation)) ShowBusStationPicker();
}
static void BuildRoadClick_TruckStation(Window *w)
{
if (HandlePlacePushButton(w, 9, 0xAA6, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker();
}
static void BuildRoadClick_Bridge(Window *w)
{
_build_road_flag = 0;
HandlePlacePushButton(w, 10, 0xA21, 1, PlaceRoad_Bridge);
}
static void BuildRoadClick_Tunnel(Window *w)
{
_build_road_flag = 0;
HandlePlacePushButton(w, 11, 0x981, 3, PlaceRoad_Tunnel);
}
static void BuildRoadClick_Remove(Window *w)
{
if (w->disabled_state & (1<<12))
return;
SetWindowDirty(w);
SndPlayFx(SND_15_BEEP);
_thd.make_square_red = !!((w->click_state ^= (1 << 12)) & (1<<12));
MarkTileDirty(_thd.pos.x, _thd.pos.y);
}
static void BuildRoadClick_Purchase(Window *w)
{
HandlePlacePushButton(w, 13, 0x12B8, 1, PlaceProc_BuyLand);
}
static OnButtonClick * const _build_road_button_proc[] = {
BuildRoadClick_NE,
BuildRoadClick_NW,
BuildRoadClick_Demolish,
BuildRoadClick_Lower,
BuildRoadClick_Raise,
BuildRoadClick_Depot,
BuildRoadClick_BusStation,
BuildRoadClick_TruckStation,
BuildRoadClick_Bridge,
BuildRoadClick_Tunnel,
BuildRoadClick_Remove,
BuildRoadClick_Purchase,
};
static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) {
switch(e->event) {
case WE_PAINT:
w->disabled_state &= ~(1 << 12);
if (!(w->click_state & 12)) {
w->disabled_state |= (1 << 12);
w->click_state &= ~(1<<12);
}
DrawWindowWidgets(w);
break;
case WE_CLICK: {
if (e->click.widget >= 2)
_build_road_button_proc[e->click.widget - 2](w);
} break;
case WE_KEYPRESS:
switch(e->keypress.keycode) {
case '1': BuildRoadClick_NE(w); break;
case '2': BuildRoadClick_NW(w); break;
case '3': BuildRoadClick_Demolish(w); break;
case '4': BuildRoadClick_Lower(w); break;
case '5': BuildRoadClick_Raise(w); break;
case 'B': BuildRoadClick_Bridge(w); break;
case 'T': BuildRoadClick_Tunnel(w); break;
case 'R': BuildRoadClick_Remove(w); break;
default:
return;
}
e->keypress.cont = false;
break;
case WE_PLACE_OBJ:
_remove_button_clicked = (w->click_state & (1 << 12)) != 0;
_place_proc(e->place.tile);
break;
case WE_ABORT_PLACE_OBJ:
w->click_state = 0;
SetWindowDirty(w);
w = FindWindowById(WC_BUS_STATION, 0);
if (w != NULL) WP(w,def_d).close=true;
w = FindWindowById(WC_TRUCK_STATION, 0);
if (w != NULL) WP(w,def_d).close=true;
w = FindWindowById(WC_BUILD_DEPOT, 0);
if (w != NULL) WP(w,def_d).close=true;
break;
case WE_PLACE_DRAG: {
int sel_method;
if (e->place.userdata == 1) {
sel_method = VPM_FIX_X;
_place_road_flag = (_place_road_flag&~2) | ((e->place.pt.y&8)>>2);
} else if (e->place.userdata == 2) {
sel_method = VPM_FIX_Y;
_place_road_flag = (_place_road_flag&~2) | ((e->place.pt.x&8)>>2);
} else if (e->place.userdata == 4) {
sel_method = VPM_X_AND_Y;
} else {
sel_method = VPM_X_OR_Y;
}
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, sel_method);
return;
}
case WE_PLACE_MOUSEUP:
if (e->place.pt.x != -1) {
uint start_tile = e->place.starttile;
uint end_tile = e->place.tile;
if (e->place.userdata == 0) {
ResetObjectToPlace();
ShowBuildBridgeWindow(start_tile, end_tile, 0x80);
} else if (e->place.userdata != 4) {
DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound1D,
_remove_button_clicked ?
CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
} else {
DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
}
}
break;
case WE_PLACE_PRESIZE: {
uint tile = e->place.tile;
DoCommandByTile(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile);
break;
}
}
}
static const Widget _build_road_widgets[] = {
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, 7, 11, 283, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, 7, 0, 21, 14, 35, 0x51D, STR_180B_BUILD_ROAD_SECTION},
{ WWT_PANEL, 7, 22, 43, 14, 35, 0x51E, STR_180B_BUILD_ROAD_SECTION},
{ WWT_PANEL, 7, 44, 65, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
{ WWT_PANEL, 7, 66, 87, 14, 35, 0x2B7, STR_018E_LOWER_A_CORNER_OF_LAND},
{ WWT_PANEL, 7, 88, 109, 14, 35, 0x2B6, STR_018F_RAISE_A_CORNER_OF_LAND},
{ WWT_PANEL, 7, 110, 131, 14, 35, 0x50F, STR_180C_BUILD_ROAD_VEHICLE_DEPOT},
{ WWT_PANEL, 7, 132, 153, 14, 35, 0x2ED, STR_180D_BUILD_BUS_STATION},
{ WWT_PANEL, 7, 154, 175, 14, 35, 0x2EE, STR_180E_BUILD_TRUCK_LOADING_BAY},
{ WWT_PANEL, 7, 176, 217, 14, 35, 0xA22, STR_180F_BUILD_ROAD_BRIDGE},
{ WWT_PANEL, 7, 218, 239, 14, 35, 0x97D, STR_1810_BUILD_ROAD_TUNNEL},
{ WWT_PANEL, 7, 240, 261, 14, 35, 0x2CA, STR_1811_TOGGLE_BUILD_REMOVE_FOR},
{ WWT_PANEL, 7, 262, 283, 14, 35, 0x12B7, STR_0329_PURCHASE_LAND_FOR_FUTURE},
{ WIDGETS_END},
};
static const WindowDesc _build_road_desc = {
356, 22, 284, 36,
WC_BUILD_TOOLBAR,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_build_road_widgets,
BuildRoadToolbWndProc
};
void ShowBuildRoadToolbar()
{
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
AllocateWindowDesc(&_build_road_desc);
}
static const Widget _build_road_scen_widgets[] = {
{ WWT_TEXTBTN, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, 7, 11, 195, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_IMGBTN, 7, 0, 21, 14, 35, 0x51D, STR_180B_BUILD_ROAD_SECTION},
{ WWT_IMGBTN, 7, 22, 43, 14, 35, 0x51E, STR_180B_BUILD_ROAD_SECTION},
{ WWT_IMGBTN, 7, 44, 65, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
{ WWT_IMGBTN, 7, 66, 87, 14, 35, 0x2B7, STR_018E_LOWER_A_CORNER_OF_LAND},
{ WWT_IMGBTN, 7, 88, 109, 14, 35, 0x2B6, STR_018F_RAISE_A_CORNER_OF_LAND},
{ WWT_EMPTY, 0, 0, 0, 0, 0, 0x0, STR_NULL},
{ WWT_EMPTY, 0, 0, 0, 0, 0, 0x0, STR_NULL},
{ WWT_EMPTY, 0, 0, 0, 0, 0, 0x0, STR_NULL},
{ WWT_IMGBTN, 7, 110, 151, 14, 35, 0xA22, STR_180F_BUILD_ROAD_BRIDGE},
{ WWT_IMGBTN, 7, 152, 173, 14, 35, 0x97D, STR_1810_BUILD_ROAD_TUNNEL},
{ WWT_IMGBTN, 7, 174, 195, 14, 35, 0x2CA, STR_1811_TOGGLE_BUILD_REMOVE_FOR},
{ WIDGETS_END},
};
static const WindowDesc _build_road_scen_desc = {
-1, -1, 196, 36,
WC_SCEN_BUILD_ROAD,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_build_road_scen_widgets,
BuildRoadToolbWndProc
};
void ShowBuildRoadScenToolbar()
{
AllocateWindowDescFront(&_build_road_scen_desc, 0);
}
static void BuildRoadDepotWndProc(Window *w, WindowEvent *e) {
switch(e->event) {
case WE_PAINT:
w->click_state = (1<<3) << _road_depot_orientation;
DrawWindowWidgets(w);
DrawRoadDepotSprite(70, 17, 0);
DrawRoadDepotSprite(70, 69, 1);
DrawRoadDepotSprite(2, 69, 2);
DrawRoadDepotSprite(2, 17, 3);
break;
case WE_CLICK: {
switch(e->click.widget) {
case 0:
ResetObjectToPlace();
break;
case 3:
case 4:
case 5:
case 6:
_road_depot_orientation = e->click.widget - 3;
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;
}
} break;
case WE_MOUSELOOP:
if (WP(w,def_d).close)
DeleteWindow(w);
break;
}
}
static const Widget _build_road_depot_widgets[] = {
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, 7, 11, 139, 0, 13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, 7, 0, 139, 14, 121, 0x0, STR_NULL},
{ WWT_PANEL, 14, 71, 136, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
{ WWT_PANEL, 14, 71, 136, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
{ WWT_PANEL, 14, 3, 68, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
{ WWT_PANEL, 14, 3, 68, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
{ WIDGETS_END},
};
static const WindowDesc _build_road_depot_desc = {
-1,-1, 140, 122,
WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_build_road_depot_widgets,
BuildRoadDepotWndProc
};
static void ShowRoadDepotPicker()
{
AllocateWindowDesc(&_build_road_depot_desc);
}
static void RoadStationPickerWndProc(Window *w, WindowEvent *e) {
switch(e->event) {
case WE_PAINT: {
int image;
w->click_state = ((1<<3) << _road_station_picker_orientation) |
((1<<7) << _station_show_coverage);
DrawWindowWidgets(w);
SetTileSelectSize(1, 1);
if (_station_show_coverage)
SetTileSelectBigSize(-4, -4, 8, 8);
image = (w->window_class == WC_BUS_STATION) ? 0x47 : 0x43;
StationPickerDrawSprite(103, 35, 0, image);
StationPickerDrawSprite(103, 85, 0, image+1);
StationPickerDrawSprite(35, 85, 0, image+2);
StationPickerDrawSprite(35, 35, 0, image+3);
DrawStringCentered(70, 120, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0);
DrawStationCoverageAreaText(2, 146,
((w->window_class == WC_BUS_STATION) ? (1<<CT_PASSENGERS) : ~(1<<CT_PASSENGERS))
);
} break;
case WE_CLICK: {
switch(e->click.widget) {
case 0:
ResetObjectToPlace();
break;
case 3:
case 4:
case 5:
case 6:
_road_station_picker_orientation = e->click.widget - 3;
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;
case 7:
case 8:
_station_show_coverage = e->click.widget - 7;
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;
}
} break;
case WE_MOUSELOOP: {
if (WP(w,def_d).close) {
DeleteWindow(w);
return;
}
CheckRedrawStationCoverage(w);
} break;
}
}
static const Widget _bus_station_picker_widgets[] = {
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, 7, 11, 139, 0, 13, STR_3042_BUS_STATION_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, 7, 0, 139, 14, 176, 0x0, STR_NULL},
{ WWT_PANEL, 14, 71, 136, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
{ WWT_PANEL, 14, 71, 136, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
{ WWT_PANEL, 14, 3, 68, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
{ WWT_PANEL, 14, 3, 68, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
{ WWT_CLOSEBOX, 14, 10, 69, 133, 144, STR_02DB_OFF,STR_3065_DON_T_HIGHLIGHT_COVERAGE},
{ WWT_CLOSEBOX, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
{ WIDGETS_END},
};
static const WindowDesc _bus_station_picker_desc = {
-1,-1, 140, 177,
WC_BUS_STATION,WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_bus_station_picker_widgets,
RoadStationPickerWndProc
};
static void ShowBusStationPicker()
{
AllocateWindowDesc(&_bus_station_picker_desc);
}
static const Widget _truck_station_picker_widgets[] = {
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, 7, 11, 139, 0, 13, STR_3043_TRUCK_STATION_ORIENT, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, 7, 0, 139, 14, 176, 0x0, STR_NULL},
{ WWT_PANEL, 14, 71, 136, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
{ WWT_PANEL, 14, 71, 136, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
{ WWT_PANEL, 14, 3, 68, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
{ WWT_PANEL, 14, 3, 68, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
{ WWT_CLOSEBOX, 14, 10, 69, 133, 144, STR_02DB_OFF,STR_3065_DON_T_HIGHLIGHT_COVERAGE},
{ WWT_CLOSEBOX, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
{ WIDGETS_END},
};
static const WindowDesc _truck_station_picker_desc = {
-1,-1, 140, 177,
WC_TRUCK_STATION,WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_truck_station_picker_widgets,
RoadStationPickerWndProc
};
static void ShowTruckStationPicker()
{
AllocateWindowDesc(&_truck_station_picker_desc);
}
void InitializeRoadGui()
{
_road_depot_orientation = 3;
_road_station_picker_orientation = 3;
}
|