Files
@ r26913:e7b3d514fe34
Branch filter:
Location: cpp/openttd-patchpack/source/src/dock_gui.cpp - annotation
r26913:e7b3d514fe34
23.1 KiB
text/x-c
Revert 92c7551: Line drawing algorithm fix broke other cases (#10497)
This reverts commit 92c755161d6a467d33477bd0041fc720d7d9ba41.
This reverts commit 92c755161d6a467d33477bd0041fc720d7d9ba41.
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 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6125:eb40461cb765 r5584:545d748cc681 r8205:096604cfa48b r8107:82461791b7a2 r8107:82461791b7a2 r8116:df67d3c5e4fd r7948:c37d06109abc r8131:7a50db7be0ff r8144:1432edd15267 r8157:cf41aa22cd09 r8224:194097dc7288 r8224:194097dc7288 r10208:ef8fcc3dc4ca r8413:49df1f427ffc r9127:933c13888121 r10208:ef8fcc3dc4ca r15410:d32a94848de6 r20388:7a2f2cbf65ab r21763:903f53f3d380 r26096:cbf789e6763e r26096:cbf789e6763e r26100:e30b0b8187b5 r26103:316b73a1be08 r26103:316b73a1be08 r5584:545d748cc681 r18670:f122c356353c r18670:f122c356353c r8264:d493cb51fe8a r8264:d493cb51fe8a r8264:d493cb51fe8a r21383:942c32fb8b0e r21383:942c32fb8b0e r9338:cde59f9097ce r9338:cde59f9097ce r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r26122:02442b0744ee r5584:545d748cc681 r14220:2b66d13ca715 r14220:2b66d13ca715 r24858:bfbc5d118b1d r14220:2b66d13ca715 r5584:545d748cc681 r5584:545d748cc681 r26122:02442b0744ee r5584:545d748cc681 r24858:bfbc5d118b1d r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r16728:0bceac8c4311 r16728:0bceac8c4311 r23023:7b8669afd1db r23023:7b8669afd1db r16728:0bceac8c4311 r16728:0bceac8c4311 r23607:36c15679007d r16728:0bceac8c4311 r18260:9616113792ef r18256:4d7d2550ba08 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r24597:afde5721a3b6 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r18256:4d7d2550ba08 r23607:36c15679007d r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r19944:25a78576fb5e r9303:118e1699967e r16221:a279f31ce838 r16221:a279f31ce838 r20280:ca1fc41725ff r9303:118e1699967e r18673:e5a4490b411b r20280:ca1fc41725ff r16150:2a38d0a45d22 r9413:fcf267325763 r9303:118e1699967e r5584:545d748cc681 r25564:c875d92c537a r9303:118e1699967e r23859:0f8a1642d1f3 r25565:6a5de7df7ea1 r25564:c875d92c537a r9303:118e1699967e r5584:545d748cc681 r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r23499:f9bf6ad58697 r16150:2a38d0a45d22 r17476:d3b7a183536d r22007:58dd28c3d424 r22007:58dd28c3d424 r22007:58dd28c3d424 r18673:e5a4490b411b r18673:e5a4490b411b r18673:e5a4490b411b r16150:2a38d0a45d22 r22007:58dd28c3d424 r25565:6a5de7df7ea1 r25565:6a5de7df7ea1 r24617:b1a2afe57776 r24609:ace2ce64471a r24617:b1a2afe57776 r24617:b1a2afe57776 r24617:b1a2afe57776 r24617:b1a2afe57776 r24617:b1a2afe57776 r24617:b1a2afe57776 r24617:b1a2afe57776 r24617:b1a2afe57776 r24617:b1a2afe57776 r24617:b1a2afe57776 r24617:b1a2afe57776 r22007:58dd28c3d424 r16150:2a38d0a45d22 r16150:2a38d0a45d22 r23499:f9bf6ad58697 r9303:118e1699967e r16800:5daa52e43961 r18673:e5a4490b411b r18673:e5a4490b411b r16800:5daa52e43961 r16800:5daa52e43961 r18673:e5a4490b411b r18673:e5a4490b411b r16800:5daa52e43961 r16800:5daa52e43961 r18673:e5a4490b411b r18673:e5a4490b411b r16800:5daa52e43961 r16800:5daa52e43961 r18673:e5a4490b411b r18673:e5a4490b411b r16800:5daa52e43961 r16800:5daa52e43961 r18673:e5a4490b411b r18673:e5a4490b411b r16800:5daa52e43961 r16800:5daa52e43961 r18673:e5a4490b411b r18673:e5a4490b411b r16800:5daa52e43961 r16800:5daa52e43961 r18673:e5a4490b411b r16801:2886e7400445 r25106:1ff7bebe2803 r16800:5daa52e43961 r16800:5daa52e43961 r18673:e5a4490b411b r18673:e5a4490b411b r16800:5daa52e43961 r16800:5daa52e43961 r17495:aa5b45c20b30 r16800:5daa52e43961 r17495:aa5b45c20b30 r5584:545d748cc681 r5584:545d748cc681 r23499:f9bf6ad58697 r9303:118e1699967e r16802:067b7b23287c r18673:e5a4490b411b r26607:9ef6fa47c216 r16802:067b7b23287c r16802:067b7b23287c r18673:e5a4490b411b r26114:91e053fa2e46 r16802:067b7b23287c r16802:067b7b23287c r18673:e5a4490b411b r16802:067b7b23287c r16802:067b7b23287c r16802:067b7b23287c r18673:e5a4490b411b r26112:8e77e1979a31 r16802:067b7b23287c r16802:067b7b23287c r18673:e5a4490b411b r16802:067b7b23287c r18247:d176683304d1 r16802:067b7b23287c r16802:067b7b23287c r26112:8e77e1979a31 r26100:e30b0b8187b5 r26100:e30b0b8187b5 r26112:8e77e1979a31 r26100:e30b0b8187b5 r26112:8e77e1979a31 r26100:e30b0b8187b5 r26100:e30b0b8187b5 r26100:e30b0b8187b5 r26100:e30b0b8187b5 r16802:067b7b23287c r16802:067b7b23287c r16802:067b7b23287c r18673:e5a4490b411b r26112:8e77e1979a31 r16802:067b7b23287c r16802:067b7b23287c r18673:e5a4490b411b r16802:067b7b23287c r16802:067b7b23287c r16802:067b7b23287c r18673:e5a4490b411b r26114:91e053fa2e46 r16802:067b7b23287c r16802:067b7b23287c r16802:067b7b23287c r16802:067b7b23287c r9303:118e1699967e r9303:118e1699967e r23499:f9bf6ad58697 r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r23499:f9bf6ad58697 r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r6670:a5c8d94cb5d7 r9303:118e1699967e r6669:831ea297162a r6670:a5c8d94cb5d7 r26114:91e053fa2e46 r9588:95c71f2b1d5b r9588:95c71f2b1d5b r26114:91e053fa2e46 r6669:831ea297162a r9303:118e1699967e r6669:831ea297162a r5584:545d748cc681 r5584:545d748cc681 r9303:118e1699967e r5584:545d748cc681 r23499:f9bf6ad58697 r9303:118e1699967e r23690:4f00d4fd22b8 r23651:51f84062abeb r9303:118e1699967e r5584:545d748cc681 r25565:6a5de7df7ea1 r25565:6a5de7df7ea1 r25565:6a5de7df7ea1 r25565:6a5de7df7ea1 r9303:118e1699967e r5584:545d748cc681 r23499:f9bf6ad58697 r9303:118e1699967e r16728:0bceac8c4311 r16728:0bceac8c4311 r18673:e5a4490b411b r16728:0bceac8c4311 r16728:0bceac8c4311 r18247:d176683304d1 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r16728:0bceac8c4311 r18673:e5a4490b411b r16728:0bceac8c4311 r16728:0bceac8c4311 r8413:49df1f427ffc r5584:545d748cc681 r5584:545d748cc681 r15410:d32a94848de6 r20397:b739fdacd6f4 r9303:118e1699967e r5584:545d748cc681 r20401:9fccb7c94c07 r20401:9fccb7c94c07 r20401:9fccb7c94c07 r20401:9fccb7c94c07 r20401:9fccb7c94c07 r20401:9fccb7c94c07 r20401:9fccb7c94c07 r20401:9fccb7c94c07 r20401:9fccb7c94c07 r23607:36c15679007d r20401:9fccb7c94c07 r20401:9fccb7c94c07 r20401:9fccb7c94c07 r15410:d32a94848de6 r15410:d32a94848de6 r20397:b739fdacd6f4 r20395:e577fdf4cfd2 r20395:e577fdf4cfd2 r20395:e577fdf4cfd2 r20395:e577fdf4cfd2 r20395:e577fdf4cfd2 r20395:e577fdf4cfd2 r20395:e577fdf4cfd2 r20395:e577fdf4cfd2 r20395:e577fdf4cfd2 r15410:d32a94848de6 r20401:9fccb7c94c07 r5584:545d748cc681 r11510:539bb875ebd0 r11510:539bb875ebd0 r18673:e5a4490b411b r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r13742:180ad925befc r13742:180ad925befc r13742:180ad925befc r11510:539bb875ebd0 r11510:539bb875ebd0 r18673:e5a4490b411b r18673:e5a4490b411b r13745:49505a0400d8 r18673:e5a4490b411b r18673:e5a4490b411b r18673:e5a4490b411b r18673:e5a4490b411b r18673:e5a4490b411b r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r20280:ca1fc41725ff r20283:2a199c78224c r5893:6c4fd9987e0f r13739:747ed1f003e3 r20399:ead82fb894d7 r20399:ead82fb894d7 r11368:058349c3a02c r5584:545d748cc681 r15418:e7ab6dbdd591 r15418:e7ab6dbdd591 r15418:e7ab6dbdd591 r15418:e7ab6dbdd591 r15418:e7ab6dbdd591 r23607:36c15679007d r15418:e7ab6dbdd591 r15418:e7ab6dbdd591 r5584:545d748cc681 r23607:36c15679007d r5584:545d748cc681 r25565:6a5de7df7ea1 r15418:e7ab6dbdd591 r5584:545d748cc681 r5584:545d748cc681 r11510:539bb875ebd0 r11510:539bb875ebd0 r18673:e5a4490b411b r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r13742:180ad925befc r13742:180ad925befc r13742:180ad925befc r11510:539bb875ebd0 r11510:539bb875ebd0 r18673:e5a4490b411b r18673:e5a4490b411b r13745:49505a0400d8 r18673:e5a4490b411b r18673:e5a4490b411b r18673:e5a4490b411b r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r11507:b8bf3eae5768 r20280:ca1fc41725ff r20283:2a199c78224c r9588:95c71f2b1d5b r13739:747ed1f003e3 r13554:d1964ead02ee r11368:058349c3a02c r9588:95c71f2b1d5b r15418:e7ab6dbdd591 r15418:e7ab6dbdd591 r15418:e7ab6dbdd591 r23607:36c15679007d r15418:e7ab6dbdd591 r15418:e7ab6dbdd591 r9588:95c71f2b1d5b r15418:e7ab6dbdd591 r9588:95c71f2b1d5b r9588:95c71f2b1d5b r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r26410:4eb5b6f65264 r11510:539bb875ebd0 r11510:539bb875ebd0 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r20280:ca1fc41725ff r9279:55dc2e3676e5 r20280:ca1fc41725ff r10565:370655f37f41 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r25564:c875d92c537a r10626:59619471b98d r25565:6a5de7df7ea1 r25564:c875d92c537a r10626:59619471b98d r10626:59619471b98d r23499:f9bf6ad58697 r9279:55dc2e3676e5 r9413:fcf267325763 r5584:545d748cc681 r9279:55dc2e3676e5 r5584:545d748cc681 r10565:370655f37f41 r6829:7110f753f2a1 r6829:7110f753f2a1 r6829:7110f753f2a1 r6829:7110f753f2a1 r5584:545d748cc681 r12355:15ed6906d629 r26410:4eb5b6f65264 r26575:d5725bf82346 r26575:d5725bf82346 r26575:d5725bf82346 r20382:ecce2523226d r20382:ecce2523226d r20382:ecce2523226d r26410:4eb5b6f65264 r26410:4eb5b6f65264 r8423:7b695adaa2cf r5584:545d748cc681 r5584:545d748cc681 r23499:f9bf6ad58697 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r10565:370655f37f41 r10565:370655f37f41 r10565:370655f37f41 r19891:7fd9bf0868c4 r9279:55dc2e3676e5 r24335:d3bd318d7a64 r5584:545d748cc681 r5584:545d748cc681 r9279:55dc2e3676e5 r5584:545d748cc681 r23499:f9bf6ad58697 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r5584:545d748cc681 r9279:55dc2e3676e5 r5584:545d748cc681 r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r13742:180ad925befc r13742:180ad925befc r11510:539bb875ebd0 r11510:539bb875ebd0 r26575:d5725bf82346 r26411:73e5a7d29025 r26411:73e5a7d29025 r26411:73e5a7d29025 r11510:539bb875ebd0 r26575:d5725bf82346 r11510:539bb875ebd0 r11510:539bb875ebd0 r11510:539bb875ebd0 r20280:ca1fc41725ff r23607:36c15679007d r5584:545d748cc681 r13739:747ed1f003e3 r13554:d1964ead02ee r11368:058349c3a02c r5584:545d748cc681 r9338:cde59f9097ce r5584:545d748cc681 r9338:cde59f9097ce r5584:545d748cc681 r5584:545d748cc681 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r5584:545d748cc681 r5584:545d748cc681 r9279:55dc2e3676e5 r20280:ca1fc41725ff r9279:55dc2e3676e5 r20280:ca1fc41725ff r18742:bb634519d745 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r5584:545d748cc681 r23499:f9bf6ad58697 r21763:903f53f3d380 r21763:903f53f3d380 r21763:903f53f3d380 r21763:903f53f3d380 r26575:d5725bf82346 r26575:d5725bf82346 r21763:903f53f3d380 r21763:903f53f3d380 r21763:903f53f3d380 r21763:903f53f3d380 r26552:7634261ba1e2 r9279:55dc2e3676e5 r26552:7634261ba1e2 r26552:7634261ba1e2 r26552:7634261ba1e2 r26552:7634261ba1e2 r26552:7634261ba1e2 r26552:7634261ba1e2 r5584:545d748cc681 r26552:7634261ba1e2 r26823:cb65f12c003b r26579:321856031c47 r26579:321856031c47 r26579:321856031c47 r26579:321856031c47 r26579:321856031c47 r26579:321856031c47 r26552:7634261ba1e2 r26552:7634261ba1e2 r26552:7634261ba1e2 r26552:7634261ba1e2 r9279:55dc2e3676e5 r5584:545d748cc681 r23499:f9bf6ad58697 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r18742:bb634519d745 r18742:bb634519d745 r18742:bb634519d745 r18742:bb634519d745 r18742:bb634519d745 r19891:7fd9bf0868c4 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r9279:55dc2e3676e5 r5584:545d748cc681 r5584:545d748cc681 r9279:55dc2e3676e5 r5584:545d748cc681 r11496:6c92713efff3 r11496:6c92713efff3 r13742:180ad925befc r13742:180ad925befc r11496:6c92713efff3 r18742:bb634519d745 r26540:5b466780f984 r26540:5b466780f984 r26540:5b466780f984 r26540:5b466780f984 r26540:5b466780f984 r11496:6c92713efff3 r26540:5b466780f984 r11496:6c92713efff3 r11496:6c92713efff3 r11496:6c92713efff3 r11496:6c92713efff3 r20280:ca1fc41725ff r23607:36c15679007d r5584:545d748cc681 r13739:747ed1f003e3 r13554:d1964ead02ee r11368:058349c3a02c r5584:545d748cc681 r5584:545d748cc681 r9338:cde59f9097ce r5584:545d748cc681 r9338:cde59f9097ce r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r6247:96e840dbefcc r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 | /*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file dock_gui.cpp GUI to create amazing water objects. */
#include "stdafx.h"
#include "terraform_gui.h"
#include "window_gui.h"
#include "station_gui.h"
#include "command_func.h"
#include "water.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "company_func.h"
#include "slope_func.h"
#include "tilehighlight_func.h"
#include "company_base.h"
#include "hotkeys.h"
#include "gui.h"
#include "zoom_func.h"
#include "tunnelbridge_cmd.h"
#include "dock_cmd.h"
#include "station_cmd.h"
#include "water_cmd.h"
#include "waypoint_cmd.h"
#include "widgets/dock_widget.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "safeguards.h"
static void ShowBuildDockStationPicker(Window *parent);
static void ShowBuildDocksDepotPicker(Window *parent);
static Axis _ship_depot_direction;
void CcBuildDocks(Commands cmd, const CommandCost &result, TileIndex tile)
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_02_CONSTRUCTION_WATER, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
void CcPlaySound_CONSTRUCTION_WATER(Commands cmd, const CommandCost &result, TileIndex tile)
{
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_CONSTRUCTION_WATER, tile);
}
/**
* Gets the other end of the aqueduct, if possible.
* @param tile_from The begin tile for the aqueduct.
* @param[out] tile_to The tile till where to show a selection for the aqueduct.
* @return The other end of the aqueduct, or otherwise a tile in line with the aqueduct to cause the right error message.
*/
static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to = nullptr)
{
int z;
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, &z));
/* If the direction isn't right, just return the next tile so the command
* complains about the wrong slope instead of the ends not matching up.
* Make sure the coordinate is always a valid tile within the map, so we
* don't go "off" the map. That would cause the wrong error message. */
if (!IsValidDiagDirection(dir)) return TILE_ADDXY(tile_from, TileX(tile_from) > 2 ? -1 : 1, 0);
/* Direction the aqueduct is built to. */
TileIndexDiff offset = TileOffsByDiagDir(ReverseDiagDir(dir));
/* The maximum length of the aqueduct. */
int max_length = std::min<int>(_settings_game.construction.max_bridge_length, DistanceFromEdgeDir(tile_from, ReverseDiagDir(dir)) - 1);
TileIndex endtile = tile_from;
for (int length = 0; IsValidTile(endtile) && TileX(endtile) != 0 && TileY(endtile) != 0; length++) {
endtile = TILE_ADD(endtile, offset);
if (length > max_length) break;
if (GetTileMaxZ(endtile) > z) {
if (tile_to != nullptr) *tile_to = endtile;
break;
}
}
return endtile;
}
/** Toolbar window for constructing water infrastructure. */
struct BuildDocksToolbarWindow : Window {
DockToolbarWidgets last_clicked_widget; ///< Contains the last widget that has been clicked on this toolbar.
BuildDocksToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{
this->last_clicked_widget = WID_DT_INVALID;
this->InitNested(window_number);
this->OnInvalidateData();
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}
void Close() override
{
if (_game_mode == GM_NORMAL && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true);
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
this->Window::Close();
}
/**
* Some data on this window has become invalid.
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
bool can_build = CanBuildVehicleInfrastructure(VEH_SHIP);
this->SetWidgetsDisabledState(!can_build,
WID_DT_DEPOT,
WID_DT_STATION,
WID_DT_BUOY,
WIDGET_LIST_END);
if (!can_build) {
CloseWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
}
if (_game_mode != GM_EDITOR) {
if (!can_build) {
/* Show in the tooltip why this button is disabled. */
this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
} else {
this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP);
this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP);
this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP);
}
}
}
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_DT_CANAL: // Build canal button
HandlePlacePushButton(this, WID_DT_CANAL, SPR_CURSOR_CANAL, HT_RECT);
break;
case WID_DT_LOCK: // Build lock button
HandlePlacePushButton(this, WID_DT_LOCK, SPR_CURSOR_LOCK, HT_SPECIAL);
break;
case WID_DT_DEMOLISH: // Demolish aka dynamite button
HandlePlacePushButton(this, WID_DT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
break;
case WID_DT_DEPOT: // Build depot button
if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT)) ShowBuildDocksDepotPicker(this);
break;
case WID_DT_STATION: // Build station button
if (HandlePlacePushButton(this, WID_DT_STATION, SPR_CURSOR_DOCK, HT_SPECIAL)) ShowBuildDockStationPicker(this);
break;
case WID_DT_BUOY: // Build buoy button
HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT);
break;
case WID_DT_RIVER: // Build river button (in scenario editor)
if (_game_mode != GM_EDITOR) return;
HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT | HT_DIAGONAL);
break;
case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
HandlePlacePushButton(this, WID_DT_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_SPECIAL);
break;
default: return;
}
this->last_clicked_widget = (DockToolbarWidgets)widget;
}
void OnPlaceObject(Point pt, TileIndex tile) override
{
switch (this->last_clicked_widget) {
case WID_DT_CANAL: // Build canal button
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_WATER);
break;
case WID_DT_LOCK: // Build lock button
Command<CMD_BUILD_LOCK>::Post(STR_ERROR_CAN_T_BUILD_LOCKS, CcBuildDocks, tile);
break;
case WID_DT_DEMOLISH: // Demolish aka dynamite button
PlaceProc_DemolishArea(tile);
break;
case WID_DT_DEPOT: // Build depot button
Command<CMD_BUILD_SHIP_DEPOT>::Post(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT, CcBuildDocks, tile, _ship_depot_direction);
break;
case WID_DT_STATION: { // Build station button
/* Determine the watery part of the dock. */
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile, ReverseDiagDir(dir)) : tile);
bool adjacent = _ctrl_pressed;
auto proc = [=](bool test, StationID to_join) -> bool {
if (test) {
return Command<CMD_BUILD_DOCK>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_DOCK>()), tile, INVALID_STATION, adjacent).Succeeded();
} else {
return Command<CMD_BUILD_DOCK>::Post(STR_ERROR_CAN_T_BUILD_DOCK_HERE, CcBuildDocks, tile, to_join, adjacent);
}
};
ShowSelectStationIfNeeded(TileArea(tile, tile_to), proc);
break;
}
case WID_DT_BUOY: // Build buoy button
Command<CMD_BUILD_BUOY>::Post(STR_ERROR_CAN_T_POSITION_BUOY_HERE, CcBuildDocks, tile);
break;
case WID_DT_RIVER: // Build river button (in scenario editor)
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_RIVER);
break;
case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
Command<CMD_BUILD_BRIDGE>::Post(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE, CcBuildBridge, tile, GetOtherAqueductEnd(tile), TRANSPORT_WATER, 0, 0);
break;
default: NOT_REACHED();
}
}
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
{
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
}
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
{
if (pt.x != -1) {
switch (select_proc) {
case DDSP_DEMOLISH_AREA:
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
break;
case DDSP_CREATE_WATER:
Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, false);
break;
case DDSP_CREATE_RIVER:
Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER, _ctrl_pressed);
break;
default: break;
}
}
}
void OnPlaceObjectAbort() override
{
if (_game_mode != GM_EDITOR && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true);
this->RaiseButtons();
CloseWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
CloseWindowById(WC_SELECT_STATION, 0);
CloseWindowByClass(WC_BUILD_BRIDGE);
}
void OnPlacePresize(Point pt, TileIndex tile_from) override
{
TileIndex tile_to = tile_from;
if (this->last_clicked_widget == WID_DT_BUILD_AQUEDUCT) {
GetOtherAqueductEnd(tile_from, &tile_to);
} else {
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from));
if (IsValidDiagDirection(dir)) {
/* Locks and docks always select the tile "down" the slope. */
tile_to = TileAddByDiagDir(tile_from, ReverseDiagDir(dir));
/* Locks also select the tile "up" the slope. */
if (this->last_clicked_widget == WID_DT_LOCK) tile_from = TileAddByDiagDir(tile_from, dir);
}
}
VpSetPresizeRange(tile_from, tile_to);
}
static HotkeyList hotkeys;
};
/**
* Handler for global hotkeys of the BuildDocksToolbarWindow.
* @param hotkey Hotkey
* @return ES_HANDLED if hotkey was accepted.
*/
static EventState DockToolbarGlobalHotkeys(int hotkey)
{
if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
Window *w = ShowBuildDocksToolbar();
if (w == nullptr) return ES_NOT_HANDLED;
return w->OnHotkey(hotkey);
}
const uint16 _dockstoolbar_aqueduct_keys[] = {'B', '8', 0};
static Hotkey dockstoolbar_hotkeys[] = {
Hotkey('1', "canal", WID_DT_CANAL),
Hotkey('2', "lock", WID_DT_LOCK),
Hotkey('3', "demolish", WID_DT_DEMOLISH),
Hotkey('4', "depot", WID_DT_DEPOT),
Hotkey('5', "dock", WID_DT_STATION),
Hotkey('6', "buoy", WID_DT_BUOY),
Hotkey('7', "river", WID_DT_RIVER),
Hotkey(_dockstoolbar_aqueduct_keys, "aqueduct", WID_DT_BUILD_AQUEDUCT),
HOTKEY_LIST_END
};
HotkeyList BuildDocksToolbarWindow::hotkeys("dockstoolbar", dockstoolbar_hotkeys, DockToolbarGlobalHotkeys);
/**
* Nested widget parts of docks toolbar, game version.
* Position of #WID_DT_RIVER widget has changed.
*/
static const NWidgetPart _nested_build_docks_toolbar_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(NWID_HORIZONTAL_LTR),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_BUILD_CANALS_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(5, 22), SetFill(1, 1), EndContainer(),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEPOT), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_SHIP_DEPOT, STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_STATION), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_SHIP_DOCK, STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUOY), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUOY, STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetMinimalSize(23, 22), SetFill(0, 1), SetDataTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
EndContainer(),
};
static WindowDesc _build_docks_toolbar_desc(
WDP_ALIGN_TOOLBAR, "toolbar_water", 0, 0,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_docks_toolbar_widgets, lengthof(_nested_build_docks_toolbar_widgets),
&BuildDocksToolbarWindow::hotkeys
);
/**
* Open the build water toolbar window
*
* If the terraform toolbar is linked to the toolbar, that window is also opened.
*
* @return newly opened water toolbar, or nullptr if the toolbar could not be opened.
*/
Window *ShowBuildDocksToolbar()
{
if (!Company::IsValidID(_local_company)) return nullptr;
CloseWindowByClass(WC_BUILD_TOOLBAR);
return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
}
/**
* Nested widget parts of docks toolbar, scenario editor version.
* Positions of #WID_DT_DEPOT, #WID_DT_STATION, and #WID_DT_BUOY widgets have changed.
*/
static const NWidgetPart _nested_build_docks_scen_toolbar_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION_SE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_CREATE_LAKE_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(5, 22), SetFill(1, 1), EndContainer(),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_RIVER), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_RIVER, STR_WATERWAYS_TOOLBAR_CREATE_RIVER_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
EndContainer(),
};
/** Window definition for the build docks in scenario editor window. */
static WindowDesc _build_docks_scen_toolbar_desc(
WDP_AUTO, "toolbar_water_scen", 0, 0,
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_docks_scen_toolbar_widgets, lengthof(_nested_build_docks_scen_toolbar_widgets)
);
/**
* Open the build water toolbar window for the scenario editor.
*
* @return newly opened water toolbar, or nullptr if the toolbar could not be opened.
*/
Window *ShowBuildDocksScenToolbar()
{
return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER);
}
/** Widget numbers of the build-dock GUI. */
enum BuildDockStationWidgets {
BDSW_BACKGROUND, ///< Background panel.
BDSW_LT_OFF, ///< 'Off' button of coverage high light.
BDSW_LT_ON, ///< 'On' button of coverage high light.
BDSW_INFO, ///< 'Coverage highlight' label.
BDSW_ACCEPTANCE, ///< Acceptance info.
};
struct BuildDocksStationWindow : public PickerWindowBase {
public:
BuildDocksStationWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->InitNested(TRANSPORT_WATER);
this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
}
void Close() override
{
CloseWindowById(WC_SELECT_STATION, 0);
this->PickerWindowBase::Close();
}
void OnPaint() override
{
int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
this->DrawWidgets();
if (_settings_client.gui.station_show_coverage) {
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
} else {
SetTileSelectSize(1, 1);
}
/* strings such as 'Size' and 'Coverage Area' */
Rect r = this->GetWidget<NWidgetBase>(BDSW_ACCEPTANCE)->GetCurrentRect();
int top = r.top + WidgetDimensions::scaled.vsep_normal;
top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + WidgetDimensions::scaled.vsep_normal;
/* Resize background if the window is too small.
* Never make the window smaller to avoid oscillating if the size change affects the acceptance.
* (This is the case, if making the window bigger moves the mouse into the window.) */
if (top > r.bottom) {
ResizeWindow(this, 0, top - r.bottom, false);
}
}
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case BDSW_LT_OFF:
case BDSW_LT_ON:
this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
_settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF);
this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->SetDirty();
SetViewportCatchmentStation(nullptr, true);
break;
}
}
void OnRealtimeTick(uint delta_ms) override
{
CheckRedrawStationCoverage(this);
}
};
/** Nested widget parts of a build dock station window. */
static const NWidgetPart _nested_build_dock_station_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_DOCK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BDSW_BACKGROUND),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BDSW_INFO), SetPadding(WidgetDimensions::unscaled.framerect), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(14, 0, 14),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_OFF), SetMinimalSize(60, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_ON), SetMinimalSize(60, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
EndContainer(),
NWidget(WWT_EMPTY, COLOUR_GREY, BDSW_ACCEPTANCE), SetPadding(WidgetDimensions::unscaled.framerect), SetResize(0, 1),
EndContainer(),
};
static WindowDesc _build_dock_station_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_dock_station_widgets, lengthof(_nested_build_dock_station_widgets)
);
static void ShowBuildDockStationPicker(Window *parent)
{
new BuildDocksStationWindow(&_build_dock_station_desc, parent);
}
struct BuildDocksDepotWindow : public PickerWindowBase {
private:
static void UpdateDocksDirection()
{
if (_ship_depot_direction != AXIS_X) {
SetTileSelectSize(1, 2);
} else {
SetTileSelectSize(2, 1);
}
}
public:
BuildDocksDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->InitNested(TRANSPORT_WATER);
this->LowerWidget(_ship_depot_direction + WID_BDD_X);
UpdateDocksDirection();
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_BDD_X:
case WID_BDD_Y:
size->width = ScaleGUITrad(96) + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Vertical();
break;
}
}
void DrawWidget(const Rect &r, int widget) const override
{
DrawPixelInfo tmp_dpi;
switch (widget) {
case WID_BDD_X:
case WID_BDD_Y: {
Axis axis = widget == WID_BDD_X ? AXIS_X : AXIS_Y;
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(96)) / 2;
int y = (r.Height() - ScaleSpriteTrad(64)) / 2;
int x1 = ScaleSpriteTrad(63);
int x2 = ScaleSpriteTrad(31);
DrawShipDepotSprite(x + (axis == AXIS_X ? x1 : x2), y + ScaleSpriteTrad(17), axis, DEPOT_PART_NORTH);
DrawShipDepotSprite(x + (axis == AXIS_X ? x2 : x1), y + ScaleSpriteTrad(33), axis, DEPOT_PART_SOUTH);
}
break;
}
}
}
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_BDD_X:
case WID_BDD_Y:
this->RaiseWidget(_ship_depot_direction + WID_BDD_X);
_ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y);
this->LowerWidget(_ship_depot_direction + WID_BDD_X);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
UpdateDocksDirection();
this->SetDirty();
break;
}
}
};
static const NWidgetPart _nested_build_docks_depot_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_DEPOT_BUILD_SHIP_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BDD_BACKGROUND),
NWidget(NWID_HORIZONTAL), SetPadding(3),
NWidget(NWID_SPACER), SetFill(1, 0),
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, 2, 0),
NWidget(WWT_PANEL, COLOUR_GREY, WID_BDD_X), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP), EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_BDD_Y), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP), EndContainer(),
EndContainer(),
NWidget(NWID_SPACER), SetFill(1, 0),
EndContainer(),
EndContainer(),
};
static WindowDesc _build_docks_depot_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_docks_depot_widgets, lengthof(_nested_build_docks_depot_widgets)
);
static void ShowBuildDocksDepotPicker(Window *parent)
{
new BuildDocksDepotWindow(&_build_docks_depot_desc, parent);
}
void InitializeDockGui()
{
_ship_depot_direction = AXIS_X;
}
|