Files
@ r23498:fcdedd342b36
Branch filter:
Location: cpp/openttd-patchpack/source/src/town_gui.cpp - annotation
r23498:fcdedd342b36
45.0 KiB
text/x-c
Codechange: Use override specifier for DropDownListItem classes.
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 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 | r5584:545d748cc681 r5584:545d748cc681 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6422:5983361e241a r5584:545d748cc681 r5584:545d748cc681 r8224:194097dc7288 r18617:524f2e0f54dc r5584:545d748cc681 r8116:df67d3c5e4fd r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r5584:545d748cc681 r17611:e84f76d88e45 r8114:866ed489ed98 r8723:866f284e9c98 r9127:933c13888121 r9387:d021ba5e6cf1 r10289:a675c6e32e39 r11206:4cc3157af9d3 r13100:30174268a209 r13100:30174268a209 r13100:30174268a209 r14248:a9050881acd7 r15521:545d58d62089 r20126:96e17e721ea3 r5584:545d748cc681 r18670:f122c356353c r18670:f122c356353c r8264:d493cb51fe8a r8264:d493cb51fe8a r21383:942c32fb8b0e r21383:942c32fb8b0e r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r13742:180ad925befc r18684:4fbd8a6351a4 r14035:4f06488d5a62 r20287:5b9a8691769e r13906:c278fe9db662 r11664:8303f25eeeb7 r18684:4fbd8a6351a4 r11664:8303f25eeeb7 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r11664:8303f25eeeb7 r18684:4fbd8a6351a4 r13720:86ccbf7d5b48 r18684:4fbd8a6351a4 r13742:180ad925befc r13720:86ccbf7d5b48 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r13076:ebc3c4e0b6c7 r9247:f6fd8323ba77 r9325:d93240a16d6a r13076:ebc3c4e0b6c7 r13076:ebc3c4e0b6c7 r15769:4a935f419828 r17533:4817e6cc66dc r9247:f6fd8323ba77 r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9627:5218d9672a1e r9325:d93240a16d6a r20280:ca1fc41725ff r9247:f6fd8323ba77 r13077:b43dcc00a2fa r20280:ca1fc41725ff r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r9247:f6fd8323ba77 r5584:545d748cc681 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r10207:a1fc2f2a33db r17533:4817e6cc66dc r17533:4817e6cc66dc r5584:545d748cc681 r15769:4a935f419828 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r18684:4fbd8a6351a4 r5584:545d748cc681 r9273:0df9c11598cc r14035:4f06488d5a62 r13077:b43dcc00a2fa r9247:f6fd8323ba77 r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r18684:4fbd8a6351a4 r13645:73efadddd32a r13645:73efadddd32a r10754:94ca54fd9e7a r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13645:73efadddd32a r13076:ebc3c4e0b6c7 r9247:f6fd8323ba77 r16016:ab5d2771109c r16016:ab5d2771109c r16016:ab5d2771109c r16016:ab5d2771109c r16017:2291ca54c6cd r16016:ab5d2771109c r16017:2291ca54c6cd r16016:ab5d2771109c r16431:ec558deca9d7 r16016:ab5d2771109c r16016:ab5d2771109c r16016:ab5d2771109c r15245:3f3838b50c07 r13645:73efadddd32a r10207:a1fc2f2a33db r10207:a1fc2f2a33db r10207:a1fc2f2a33db r10207:a1fc2f2a33db r16016:ab5d2771109c r5584:545d748cc681 r10207:a1fc2f2a33db r10207:a1fc2f2a33db r9247:f6fd8323ba77 r10207:a1fc2f2a33db r23466:fe090075b7cb r23466:fe090075b7cb r23466:fe090075b7cb r23466:fe090075b7cb r23466:fe090075b7cb r23466:fe090075b7cb r23466:fe090075b7cb r23466:fe090075b7cb r5584:545d748cc681 r9247:f6fd8323ba77 r15245:3f3838b50c07 r16017:2291ca54c6cd r9247:f6fd8323ba77 r9247:f6fd8323ba77 r13645:73efadddd32a r13076:ebc3c4e0b6c7 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r10755:cec7b19b59cf r13077:b43dcc00a2fa r13077:b43dcc00a2fa r10755:cec7b19b59cf r22382:2fb5fdebf2bb r10755:cec7b19b59cf r13077:b43dcc00a2fa r10755:cec7b19b59cf r13077:b43dcc00a2fa r13077:b43dcc00a2fa r18684:4fbd8a6351a4 r13077:b43dcc00a2fa r5584:545d748cc681 r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r18684:4fbd8a6351a4 r13077:b43dcc00a2fa r14397:7a7b8c49c4ab r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r18684:4fbd8a6351a4 r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r15769:4a935f419828 r9247:f6fd8323ba77 r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r9247:f6fd8323ba77 r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r14397:7a7b8c49c4ab r14397:7a7b8c49c4ab r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r9247:f6fd8323ba77 r9247:f6fd8323ba77 r13077:b43dcc00a2fa r5584:545d748cc681 r13695:e0bf1a35834a r13077:b43dcc00a2fa r13077:b43dcc00a2fa r18684:4fbd8a6351a4 r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r14397:7a7b8c49c4ab r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r13077:b43dcc00a2fa r18684:4fbd8a6351a4 r13077:b43dcc00a2fa r13720:86ccbf7d5b48 r13720:86ccbf7d5b48 r13720:86ccbf7d5b48 r13720:86ccbf7d5b48 r13720:86ccbf7d5b48 r13077:b43dcc00a2fa r13077:b43dcc00a2fa r18684:4fbd8a6351a4 r13720:86ccbf7d5b48 r13077:b43dcc00a2fa r13077:b43dcc00a2fa r9247:f6fd8323ba77 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r14399:3f819c0da60a r9247:f6fd8323ba77 r9247:f6fd8323ba77 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r15769:4a935f419828 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r5584:545d748cc681 r22672:3473f7daf422 r14399:3f819c0da60a r22850:1d6a79ca3a7c r5584:545d748cc681 r8932:4b84f158c23d r18684:4fbd8a6351a4 r11725:57bc99fdc1bc r9247:f6fd8323ba77 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r5584:545d748cc681 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r9247:f6fd8323ba77 r5584:545d748cc681 r9247:f6fd8323ba77 r5584:545d748cc681 r20280:ca1fc41725ff r20283:2a199c78224c r5893:6c4fd9987e0f r19745:d8f95208ad9e r13554:d1964ead02ee r11368:058349c3a02c r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r9247:f6fd8323ba77 r5584:545d748cc681 r5584:545d748cc681 r11662:53d3b28fa13c r13059:3c0354738822 r9325:d93240a16d6a r9325:d93240a16d6a r13059:3c0354738822 r8933:d98e0783fa25 r9325:d93240a16d6a r18684:4fbd8a6351a4 r11206:4cc3157af9d3 r20280:ca1fc41725ff r9287:b6ae9c25c177 r20280:ca1fc41725ff r13059:3c0354738822 r13061:b128884f3953 r18684:4fbd8a6351a4 r13059:3c0354738822 r20280:ca1fc41725ff r5584:545d748cc681 r18927:27f5bdeb2fef r18684:4fbd8a6351a4 r13059:3c0354738822 r9308:82b4df28e98e r13059:3c0354738822 r18684:4fbd8a6351a4 r9287:b6ae9c25c177 r8717:72d82b7a0f93 r13059:3c0354738822 r13059:3c0354738822 r18684:4fbd8a6351a4 r13059:3c0354738822 r5584:545d748cc681 r13059:3c0354738822 r13059:3c0354738822 r18684:4fbd8a6351a4 r13059:3c0354738822 r13059:3c0354738822 r11206:4cc3157af9d3 r19276:ad854f3053cd r19276:ad854f3053cd r13059:3c0354738822 r5584:545d748cc681 r22881:26c6178de2ff r22881:26c6178de2ff r22881:26c6178de2ff r22881:26c6178de2ff r5584:545d748cc681 r22881:26c6178de2ff r22881:26c6178de2ff r22881:26c6178de2ff r22881:26c6178de2ff r11206:4cc3157af9d3 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r19276:ad854f3053cd r19276:ad854f3053cd r11206:4cc3157af9d3 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r11206:4cc3157af9d3 r16431:ec558deca9d7 r13792:7debd79a9949 r13792:7debd79a9949 r13792:7debd79a9949 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r13877:8db2e878ed67 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18620:58c471335930 r18446:7b57061bbb9d r11206:4cc3157af9d3 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r11206:4cc3157af9d3 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r11206:4cc3157af9d3 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r11206:4cc3157af9d3 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r20878:f8e3794f90de r22857:c20a34513570 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r11206:4cc3157af9d3 r9287:b6ae9c25c177 r9334:6d079081ec24 r9413:fcf267325763 r9334:6d079081ec24 r9334:6d079081ec24 r13059:3c0354738822 r9334:6d079081ec24 r18768:3747fd5dec42 r18768:3747fd5dec42 r18778:4848b0595531 r21716:d892747529d1 r18768:3747fd5dec42 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r14399:3f819c0da60a r9287:b6ae9c25c177 r9287:b6ae9c25c177 r18684:4fbd8a6351a4 r9287:b6ae9c25c177 r9326:ad1660d36a2b r9287:b6ae9c25c177 r9326:ad1660d36a2b r9287:b6ae9c25c177 r9287:b6ae9c25c177 r5584:545d748cc681 r18684:4fbd8a6351a4 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r5584:545d748cc681 r18684:4fbd8a6351a4 r9287:b6ae9c25c177 r17569:79cc833a8f35 r9287:b6ae9c25c177 r5584:545d748cc681 r18684:4fbd8a6351a4 r15647:143f3f9972e7 r15647:143f3f9972e7 r15647:143f3f9972e7 r15647:143f3f9972e7 r15647:143f3f9972e7 r15647:143f3f9972e7 r15647:143f3f9972e7 r15647:143f3f9972e7 r15647:143f3f9972e7 r9287:b6ae9c25c177 r15650:931acc233df9 r5584:545d748cc681 r18684:4fbd8a6351a4 r15648:c23281f890bf r9287:b6ae9c25c177 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r5584:545d748cc681 r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r18684:4fbd8a6351a4 r18768:3747fd5dec42 r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r18768:3747fd5dec42 r11206:4cc3157af9d3 r13059:3c0354738822 r11206:4cc3157af9d3 r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r19276:ad854f3053cd r19276:ad854f3053cd r18456:6f225e779d6a r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r18446:7b57061bbb9d r11206:4cc3157af9d3 r18446:7b57061bbb9d r11206:4cc3157af9d3 r13059:3c0354738822 r11206:4cc3157af9d3 r18768:3747fd5dec42 r18768:3747fd5dec42 r21716:d892747529d1 r18768:3747fd5dec42 r18768:3747fd5dec42 r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r13728:fbfc7dc4defe r18684:4fbd8a6351a4 r18768:3747fd5dec42 r13059:3c0354738822 r13728:fbfc7dc4defe r13059:3c0354738822 r13059:3c0354738822 r13059:3c0354738822 r13334:52f3226937dd r13059:3c0354738822 r13059:3c0354738822 r18684:4fbd8a6351a4 r13059:3c0354738822 r16304:63adae3094ef r16304:63adae3094ef r13059:3c0354738822 r11206:4cc3157af9d3 r11206:4cc3157af9d3 r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r9334:6d079081ec24 r17476:d3b7a183536d r18668:b656d614c4fd r9334:6d079081ec24 r11206:4cc3157af9d3 r9334:6d079081ec24 r9334:6d079081ec24 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r10148:ec65442a5187 r10148:ec65442a5187 r11725:57bc99fdc1bc r5584:545d748cc681 r9287:b6ae9c25c177 r5584:545d748cc681 r13059:3c0354738822 r13059:3c0354738822 r13742:180ad925befc r18684:4fbd8a6351a4 r14035:4f06488d5a62 r20287:5b9a8691769e r13742:180ad925befc r13059:3c0354738822 r13745:49505a0400d8 r13745:49505a0400d8 r18684:4fbd8a6351a4 r13059:3c0354738822 r13059:3c0354738822 r18684:4fbd8a6351a4 r13728:fbfc7dc4defe r13728:fbfc7dc4defe r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r13728:fbfc7dc4defe r13742:180ad925befc r13059:3c0354738822 r5584:545d748cc681 r5584:545d748cc681 r20280:ca1fc41725ff r20283:2a199c78224c r13059:3c0354738822 r19745:d8f95208ad9e r13554:d1964ead02ee r13059:3c0354738822 r13059:3c0354738822 r13059:3c0354738822 r11664:8303f25eeeb7 r13742:180ad925befc r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r14035:4f06488d5a62 r20287:5b9a8691769e r13742:180ad925befc r11664:8303f25eeeb7 r13745:49505a0400d8 r13745:49505a0400d8 r18684:4fbd8a6351a4 r13059:3c0354738822 r11664:8303f25eeeb7 r18684:4fbd8a6351a4 r13728:fbfc7dc4defe r13728:fbfc7dc4defe r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r13728:fbfc7dc4defe r13742:180ad925befc r11664:8303f25eeeb7 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r20280:ca1fc41725ff r20283:2a199c78224c r5893:6c4fd9987e0f r19745:d8f95208ad9e r13554:d1964ead02ee r11368:058349c3a02c r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r13059:3c0354738822 r13059:3c0354738822 r13059:3c0354738822 r13059:3c0354738822 r13059:3c0354738822 r5584:545d748cc681 r5584:545d748cc681 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r13742:180ad925befc r13742:180ad925befc r14035:4f06488d5a62 r20287:5b9a8691769e r13742:180ad925befc r11664:8303f25eeeb7 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r11664:8303f25eeeb7 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r12505:2c7de3127b25 r11664:8303f25eeeb7 r12505:2c7de3127b25 r18684:4fbd8a6351a4 r13742:180ad925befc r12505:2c7de3127b25 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r5584:545d748cc681 r12263:5b872c6d772b r9312:2ba1f9cef4e2 r9325:d93240a16d6a r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r20126:96e17e721ea3 r9390:aab57f0a7820 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r15769:4a935f419828 r15769:4a935f419828 r12306:302475677258 r9387:d021ba5e6cf1 r12306:302475677258 r12306:302475677258 r9387:d021ba5e6cf1 r12306:302475677258 r12306:302475677258 r12306:302475677258 r12306:302475677258 r9387:d021ba5e6cf1 r12306:302475677258 r12306:302475677258 r15769:4a935f419828 r12306:302475677258 r12306:302475677258 r12821:9f4433370d17 r9387:d021ba5e6cf1 r20126:96e17e721ea3 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r12442:2de615d6604d r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r19944:25a78576fb5e r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r12442:2de615d6604d r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r16604:2b94452893e9 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r20128:dd94e6f8bada r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r20128:dd94e6f8bada r20128:dd94e6f8bada r20128:dd94e6f8bada r20594:a26544fdc268 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20594:a26544fdc268 r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r9325:d93240a16d6a r20280:ca1fc41725ff r9312:2ba1f9cef4e2 r20280:ca1fc41725ff r15769:4a935f419828 r18684:4fbd8a6351a4 r15769:4a935f419828 r9387:d021ba5e6cf1 r12821:9f4433370d17 r9387:d021ba5e6cf1 r12306:302475677258 r12312:2fd21a2eeca2 r20280:ca1fc41725ff r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r12506:9513e5fe26bf r12506:9513e5fe26bf r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r12506:9513e5fe26bf r12506:9513e5fe26bf r22919:dfa6f4299122 r22919:dfa6f4299122 r22919:dfa6f4299122 r22919:dfa6f4299122 r22919:dfa6f4299122 r22919:dfa6f4299122 r22919:dfa6f4299122 r22919:dfa6f4299122 r22919:dfa6f4299122 r22919:dfa6f4299122 r12264:fea334a13752 r12264:fea334a13752 r12666:f45560c3fe4d r20126:96e17e721ea3 r20126:96e17e721ea3 r12264:fea334a13752 r9312:2ba1f9cef4e2 r18684:4fbd8a6351a4 r12264:fea334a13752 r12823:d4e0cff57b25 r12920:bb693de6a7ca r12920:bb693de6a7ca r12920:bb693de6a7ca r12920:bb693de6a7ca r19238:a595a403afc1 r12920:bb693de6a7ca r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r15769:4a935f419828 r12264:fea334a13752 r19238:a595a403afc1 r12264:fea334a13752 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r9312:2ba1f9cef4e2 r12264:fea334a13752 r19276:ad854f3053cd r22919:dfa6f4299122 r5584:545d748cc681 r12823:d4e0cff57b25 r15769:4a935f419828 r12264:fea334a13752 r15608:7b580ec7448a r15608:7b580ec7448a r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r5584:545d748cc681 r13695:e0bf1a35834a r12313:f8317da11c46 r12313:f8317da11c46 r20126:96e17e721ea3 r13062:680961bd134a r21814:76dbe7ca0bbf r12427:88c1949f3666 r12427:88c1949f3666 r12313:f8317da11c46 r12313:f8317da11c46 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r18684:4fbd8a6351a4 r12920:bb693de6a7ca r12313:f8317da11c46 r12313:f8317da11c46 r12313:f8317da11c46 r12313:f8317da11c46 r12313:f8317da11c46 r12313:f8317da11c46 r19846:75a27628493b r22919:dfa6f4299122 r12313:f8317da11c46 r19238:a595a403afc1 r19238:a595a403afc1 r19238:a595a403afc1 r15822:4c0c8f3f8af8 r15822:4c0c8f3f8af8 r12823:d4e0cff57b25 r15822:4c0c8f3f8af8 r12427:88c1949f3666 r12313:f8317da11c46 r12427:88c1949f3666 r18684:4fbd8a6351a4 r19846:75a27628493b r12427:88c1949f3666 r12427:88c1949f3666 r12427:88c1949f3666 r12427:88c1949f3666 r12313:f8317da11c46 r12427:88c1949f3666 r12313:f8317da11c46 r12313:f8317da11c46 r12313:f8317da11c46 r14399:3f819c0da60a r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r20126:96e17e721ea3 r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r20129:66607208a9cc r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r5584:545d748cc681 r20126:96e17e721ea3 r20126:96e17e721ea3 r9312:2ba1f9cef4e2 r5584:545d748cc681 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r9387:d021ba5e6cf1 r5584:545d748cc681 r9387:d021ba5e6cf1 r12313:f8317da11c46 r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r8932:4b84f158c23d r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r5584:545d748cc681 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20127:60d8306e833a r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r17463:0e77af810a2d r17463:0e77af810a2d r17463:0e77af810a2d r17463:0e77af810a2d r17463:0e77af810a2d r17463:0e77af810a2d r9312:2ba1f9cef4e2 r9312:2ba1f9cef4e2 r12306:302475677258 r9312:2ba1f9cef4e2 r5584:545d748cc681 r9312:2ba1f9cef4e2 r13334:52f3226937dd r9312:2ba1f9cef4e2 r18684:4fbd8a6351a4 r9312:2ba1f9cef4e2 r9387:d021ba5e6cf1 r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r17482:4dbb8b190ff9 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20129:66607208a9cc r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r20126:96e17e721ea3 r9390:aab57f0a7820 r9387:d021ba5e6cf1 r9387:d021ba5e6cf1 r20129:66607208a9cc r9312:2ba1f9cef4e2 r5584:545d748cc681 r20280:ca1fc41725ff r20283:2a199c78224c r5893:6c4fd9987e0f r19745:d8f95208ad9e r13554:d1964ead02ee r11368:058349c3a02c r5584:545d748cc681 r6247:96e840dbefcc r5584:545d748cc681 r9347:7ba3578fd044 r9312:2ba1f9cef4e2 r5584:545d748cc681 r8723:866f284e9c98 r14220:2b66d13ca715 r8723:866f284e9c98 r14220:2b66d13ca715 r14220:2b66d13ca715 r21328:def02569ef03 r14220:2b66d13ca715 r8723:866f284e9c98 r8723:866f284e9c98 r14220:2b66d13ca715 r13097:c59fc0ed2eeb r14220:2b66d13ca715 r13097:c59fc0ed2eeb r13097:c59fc0ed2eeb r11664:8303f25eeeb7 r11664:8303f25eeeb7 r13742:180ad925befc r13742:180ad925befc r14035:4f06488d5a62 r13742:180ad925befc r11664:8303f25eeeb7 r11664:8303f25eeeb7 r18684:4fbd8a6351a4 r11664:8303f25eeeb7 r18684:4fbd8a6351a4 r12307:e282097c0aa0 r19742:eb30b96c01c2 r11725:57bc99fdc1bc r19742:eb30b96c01c2 r12622:202e83a6cee7 r13100:30174268a209 r18684:4fbd8a6351a4 r19792:9638b58d8322 r14043:1019a339e9af r19742:eb30b96c01c2 r13100:30174268a209 r11664:8303f25eeeb7 r14043:1019a339e9af r13694:4523784084b5 r18684:4fbd8a6351a4 r13694:4523784084b5 r11664:8303f25eeeb7 r12307:e282097c0aa0 r18684:4fbd8a6351a4 r12307:e282097c0aa0 r18684:4fbd8a6351a4 r12307:e282097c0aa0 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r12307:e282097c0aa0 r18684:4fbd8a6351a4 r12307:e282097c0aa0 r18684:4fbd8a6351a4 r12622:202e83a6cee7 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r18684:4fbd8a6351a4 r13694:4523784084b5 r11664:8303f25eeeb7 r14043:1019a339e9af r13694:4523784084b5 r18684:4fbd8a6351a4 r13694:4523784084b5 r11664:8303f25eeeb7 r12307:e282097c0aa0 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r12307:e282097c0aa0 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r18684:4fbd8a6351a4 r13694:4523784084b5 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r11664:8303f25eeeb7 r12263:5b872c6d772b r19787:20d2473dd1cb r9325:d93240a16d6a r13032:03a8e9583743 r13032:03a8e9583743 r13032:03a8e9583743 r19787:20d2473dd1cb r13100:30174268a209 r13100:30174268a209 r13100:30174268a209 r11016:3618f03dd597 r9325:d93240a16d6a r20280:ca1fc41725ff r20280:ca1fc41725ff r14872:dfad0b6fd384 r13032:03a8e9583743 r19787:20d2473dd1cb r13100:30174268a209 r9287:b6ae9c25c177 r20280:ca1fc41725ff r19787:20d2473dd1cb r13100:30174268a209 r13746:3eeb0ceed378 r11017:d4dcb3ea110b r11017:d4dcb3ea110b r13100:30174268a209 r13100:30174268a209 r13100:30174268a209 r13100:30174268a209 r13100:30174268a209 r19787:20d2473dd1cb r13100:30174268a209 r19787:20d2473dd1cb r19787:20d2473dd1cb r13100:30174268a209 r18684:4fbd8a6351a4 r13100:30174268a209 r18684:4fbd8a6351a4 r13100:30174268a209 r13100:30174268a209 r13746:3eeb0ceed378 r11017:d4dcb3ea110b r13746:3eeb0ceed378 r18684:4fbd8a6351a4 r13746:3eeb0ceed378 r18684:4fbd8a6351a4 r13746:3eeb0ceed378 r13746:3eeb0ceed378 r13746:3eeb0ceed378 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r11017:d4dcb3ea110b r11017:d4dcb3ea110b r18684:4fbd8a6351a4 r11017:d4dcb3ea110b r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r11017:d4dcb3ea110b r11017:d4dcb3ea110b r11017:d4dcb3ea110b r9287:b6ae9c25c177 r8723:866f284e9c98 r13097:c59fc0ed2eeb r13097:c59fc0ed2eeb r13100:30174268a209 r13100:30174268a209 r13100:30174268a209 r19787:20d2473dd1cb r13100:30174268a209 r13100:30174268a209 r16673:d4cdf063a299 r13100:30174268a209 r19787:20d2473dd1cb r13097:c59fc0ed2eeb r13097:c59fc0ed2eeb r13100:30174268a209 r13100:30174268a209 r13100:30174268a209 r22168:1893a43131f7 r22168:1893a43131f7 r13097:c59fc0ed2eeb r13097:c59fc0ed2eeb r14399:3f819c0da60a r9287:b6ae9c25c177 r9287:b6ae9c25c177 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r9287:b6ae9c25c177 r8932:4b84f158c23d r18684:4fbd8a6351a4 r13097:c59fc0ed2eeb r13097:c59fc0ed2eeb r8932:4b84f158c23d r18684:4fbd8a6351a4 r13100:30174268a209 r18684:4fbd8a6351a4 r13100:30174268a209 r13100:30174268a209 r18684:4fbd8a6351a4 r9287:b6ae9c25c177 r10340:90705a3f079d r13032:03a8e9583743 r14635:a75264d517b7 r10289:a675c6e32e39 r10340:90705a3f079d r9287:b6ae9c25c177 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r13746:3eeb0ceed378 r11013:56b9237ed0b5 r11013:56b9237ed0b5 r18684:4fbd8a6351a4 r13032:03a8e9583743 r18684:4fbd8a6351a4 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r11002:ca78de6e5555 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r18684:4fbd8a6351a4 r13746:3eeb0ceed378 r11002:ca78de6e5555 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r8723:866f284e9c98 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r13097:c59fc0ed2eeb r8723:866f284e9c98 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r13746:3eeb0ceed378 r13746:3eeb0ceed378 r13746:3eeb0ceed378 r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r17476:d3b7a183536d r13746:3eeb0ceed378 r17476:d3b7a183536d r13746:3eeb0ceed378 r9287:b6ae9c25c177 r9287:b6ae9c25c177 r8723:866f284e9c98 r20280:ca1fc41725ff r20283:2a199c78224c r11156:94cc27f7f726 r19745:d8f95208ad9e r13554:d1964ead02ee r11368:058349c3a02c r8723:866f284e9c98 r13092:7d6dcd5428fd r8723:866f284e9c98 r11919:363b629324b9 r11156:94cc27f7f726 r8723:866f284e9c98 | /* $Id$ */
/*
* 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 town_gui.cpp GUI for towns. */
#include "stdafx.h"
#include "town.h"
#include "viewport_func.h"
#include "error.h"
#include "gui.h"
#include "command_func.h"
#include "company_func.h"
#include "company_base.h"
#include "company_gui.h"
#include "network/network.h"
#include "string_func.h"
#include "strings_func.h"
#include "sound_func.h"
#include "tilehighlight_func.h"
#include "sortlist_type.h"
#include "road_cmd.h"
#include "landscape.h"
#include "querystring_gui.h"
#include "window_func.h"
#include "townname_func.h"
#include "core/geometry_func.hpp"
#include "genworld.h"
#include "widgets/dropdown_func.h"
#include "widgets/town_widget.h"
#include "table/strings.h"
#include "safeguards.h"
typedef GUIList<const Town*> GUITownList;
static const NWidgetPart _nested_town_authority_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TA_CAPTION), SetDataTip(STR_LOCAL_AUTHORITY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_RATING_INFO), SetMinimalSize(317, 92), SetResize(1, 1), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_COMMAND_LIST), SetMinimalSize(305, 52), SetResize(1, 0), SetDataTip(0x0, STR_LOCAL_AUTHORITY_ACTIONS_TOOLTIP), SetScrollbar(WID_TA_SCROLLBAR), EndContainer(),
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_TA_SCROLLBAR),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_ACTION_INFO), SetMinimalSize(317, 52), SetResize(1, 0), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TA_EXECUTE), SetMinimalSize(317, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_LOCAL_AUTHORITY_DO_IT_BUTTON, STR_LOCAL_AUTHORITY_DO_IT_TOOLTIP),
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
EndContainer()
};
/** Town authority window. */
struct TownAuthorityWindow : Window {
private:
Town *town; ///< Town being displayed.
int sel_index; ///< Currently selected town action, \c 0 to \c TACT_COUNT-1, \c -1 means no action selected.
Scrollbar *vscroll;
uint displayed_actions_on_previous_painting; ///< Actions that were available on the previous call to OnPaint()
/**
* Get the position of the Nth set bit.
*
* If there is no Nth bit set return -1
*
* @param bits The value to search in
* @param n The Nth set bit from which we want to know the position
* @return The position of the Nth set bit
*/
static int GetNthSetBit(uint32 bits, int n)
{
if (n >= 0) {
uint i;
FOR_EACH_SET_BIT(i, bits) {
n--;
if (n < 0) return i;
}
}
return -1;
}
public:
TownAuthorityWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), sel_index(-1), displayed_actions_on_previous_painting(0)
{
this->town = Town::Get(window_number);
this->InitNested(window_number);
this->vscroll = this->GetScrollbar(WID_TA_SCROLLBAR);
this->vscroll->SetCapacity((this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / FONT_HEIGHT_NORMAL);
}
virtual void OnPaint()
{
int numact;
uint buttons = GetMaskOfTownActions(&numact, _local_company, this->town);
if (buttons != displayed_actions_on_previous_painting) this->SetDirty();
displayed_actions_on_previous_painting = buttons;
this->vscroll->SetCount(numact + 1);
if (this->sel_index != -1 && !HasBit(buttons, this->sel_index)) {
this->sel_index = -1;
}
this->SetWidgetDisabledState(WID_TA_EXECUTE, this->sel_index == -1);
this->DrawWidgets();
if (!this->IsShaded()) this->DrawRatings();
}
/** Draw the contents of the ratings panel. May request a resize of the window if the contents does not fit. */
void DrawRatings()
{
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_TA_RATING_INFO);
uint left = nwid->pos_x + WD_FRAMERECT_LEFT;
uint right = nwid->pos_x + nwid->current_x - 1 - WD_FRAMERECT_RIGHT;
uint y = nwid->pos_y + WD_FRAMERECT_TOP;
DrawString(left, right, y, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
y += FONT_HEIGHT_NORMAL;
Dimension icon_size = GetSpriteSize(SPR_COMPANY_ICON);
int icon_width = icon_size.width;
int icon_y_offset = (FONT_HEIGHT_NORMAL - icon_size.height) / 2;
Dimension exclusive_size = GetSpriteSize(SPR_EXCLUSIVE_TRANSPORT);
int exclusive_width = exclusive_size.width;
int exclusive_y_offset = (FONT_HEIGHT_NORMAL - exclusive_size.height) / 2;
bool rtl = _current_text_dir == TD_RTL;
uint text_left = left + (rtl ? 0 : icon_width + exclusive_width + 4);
uint text_right = right - (rtl ? icon_width + exclusive_width + 4 : 0);
uint icon_left = rtl ? right - icon_width : left;
uint exclusive_left = rtl ? right - icon_width - exclusive_width - 2 : left + icon_width + 2;
/* Draw list of companies */
const Company *c;
FOR_ALL_COMPANIES(c) {
if ((HasBit(this->town->have_ratings, c->index) || this->town->exclusivity == c->index)) {
DrawCompanyIcon(c->index, icon_left, y + icon_y_offset);
SetDParam(0, c->index);
SetDParam(1, c->index);
int r = this->town->ratings[c->index];
StringID str = STR_CARGO_RATING_APPALLING;
if (r > RATING_APPALLING) str++;
if (r > RATING_VERYPOOR) str++;
if (r > RATING_POOR) str++;
if (r > RATING_MEDIOCRE) str++;
if (r > RATING_GOOD) str++;
if (r > RATING_VERYGOOD) str++;
if (r > RATING_EXCELLENT) str++;
SetDParam(2, str);
if (this->town->exclusivity == c->index) {
DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->index), exclusive_left, y + exclusive_y_offset);
}
DrawString(text_left, text_right, y, STR_LOCAL_AUTHORITY_COMPANY_RATING);
y += FONT_HEIGHT_NORMAL;
}
}
y = y + WD_FRAMERECT_BOTTOM - nwid->pos_y; // Compute needed size of the widget.
if (y > nwid->current_y) {
/* If the company list is too big to fit, mark ourself dirty and draw again. */
ResizeWindow(this, 0, y - nwid->current_y, false);
}
}
virtual void SetStringParameters(int widget) const
{
if (widget == WID_TA_CAPTION) SetDParam(0, this->window_number);
}
virtual void DrawWidget(const Rect &r, int widget) const
{
switch (widget) {
case WID_TA_ACTION_INFO:
if (this->sel_index != -1) {
SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[this->sel_index] >> 8);
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + this->sel_index);
}
break;
case WID_TA_COMMAND_LIST: {
int numact;
uint buttons = GetMaskOfTownActions(&numact, _local_company, this->town);
int y = r.top + WD_FRAMERECT_TOP;
int pos = this->vscroll->GetPosition();
if (--pos < 0) {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_LOCAL_AUTHORITY_ACTIONS_TITLE);
y += FONT_HEIGHT_NORMAL;
}
for (int i = 0; buttons; i++, buttons >>= 1) {
if (pos <= -5) break; ///< Draw only the 5 fitting lines
if ((buttons & 1) && --pos < 0) {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y,
STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, this->sel_index == i ? TC_WHITE : TC_ORANGE);
y += FONT_HEIGHT_NORMAL;
}
}
break;
}
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
case WID_TA_ACTION_INFO: {
assert(size->width > padding.width && size->height > padding.height);
size->width -= WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
size->height -= WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
Dimension d = {0, 0};
for (int i = 0; i < TACT_COUNT; i++) {
SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[i] >> 8);
d = maxdim(d, GetStringMultiLineBoundingBox(STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + i, *size));
}
*size = maxdim(*size, d);
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
size->height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
break;
}
case WID_TA_COMMAND_LIST:
size->height = WD_FRAMERECT_TOP + 5 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
size->width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width;
for (uint i = 0; i < TACT_COUNT; i++ ) {
size->width = max(size->width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width);
}
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
break;
case WID_TA_RATING_INFO:
resize->height = FONT_HEIGHT_NORMAL;
size->height = WD_FRAMERECT_TOP + 9 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
break;
}
}
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case WID_TA_COMMAND_LIST: {
int y = this->GetRowFromWidget(pt.y, WID_TA_COMMAND_LIST, 1, FONT_HEIGHT_NORMAL);
if (!IsInsideMM(y, 0, 5)) return;
y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_company, this->town), y + this->vscroll->GetPosition() - 1);
if (y >= 0) {
this->sel_index = y;
this->SetDirty();
}
/* When double-clicking, continue */
if (click_count == 1 || y < 0) break;
FALLTHROUGH;
}
case WID_TA_EXECUTE:
DoCommandP(this->town->xy, this->window_number, this->sel_index, CMD_DO_TOWN_ACTION | CMD_MSG(STR_ERROR_CAN_T_DO_THIS));
break;
}
}
virtual void OnHundredthTick()
{
this->SetDirty();
}
};
static WindowDesc _town_authority_desc(
WDP_AUTO, "view_town_authority", 317, 222,
WC_TOWN_AUTHORITY, WC_NONE,
0,
_nested_town_authority_widgets, lengthof(_nested_town_authority_widgets)
);
static void ShowTownAuthorityWindow(uint town)
{
AllocateWindowDescFront<TownAuthorityWindow>(&_town_authority_desc, town);
}
/* Town view window. */
struct TownViewWindow : Window {
private:
Town *town; ///< Town displayed by the window.
public:
static const int WID_TV_HEIGHT_NORMAL = 150;
TownViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{
this->CreateNestedTree();
this->town = Town::Get(window_number);
if (this->town->larger_town) this->GetWidget<NWidgetCore>(WID_TV_CAPTION)->widget_data = STR_TOWN_VIEW_CITY_CAPTION;
this->FinishInitNested(window_number);
this->flags |= WF_DISABLE_VP_SCROLL;
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_TV_VIEWPORT);
nvp->InitializeViewport(this, this->town->xy, ZOOM_LVL_NEWS);
/* disable renaming town in network games if you are not the server */
this->SetWidgetDisabledState(WID_TV_CHANGE_NAME, _networking && !_network_server);
}
virtual void SetStringParameters(int widget) const
{
if (widget == WID_TV_CAPTION) SetDParam(0, this->town->index);
}
virtual void DrawWidget(const Rect &r, int widget) const
{
if (widget != WID_TV_INFO) return;
uint y = r.top + WD_FRAMERECT_TOP;
SetDParam(0, this->town->cache.population);
SetDParam(1, this->town->cache.num_houses);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_VIEW_POPULATION_HOUSES);
SetDParam(0, 1 << CT_PASSENGERS);
SetDParam(1, this->town->supplied[CT_PASSENGERS].old_act);
SetDParam(2, this->town->supplied[CT_PASSENGERS].old_max);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
SetDParam(0, 1 << CT_MAIL);
SetDParam(1, this->town->supplied[CT_MAIL].old_act);
SetDParam(2, this->town->supplied[CT_MAIL].old_max);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
bool first = true;
for (int i = TE_BEGIN; i < TE_END; i++) {
if (this->town->goal[i] == 0) continue;
if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue;
if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;
if (first) {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
first = false;
}
bool rtl = _current_text_dir == TD_RTL;
uint cargo_text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : 20);
uint cargo_text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? 20 : 0);
const CargoSpec *cargo = FindFirstCargoWithTownEffect((TownEffect)i);
assert(cargo != NULL);
StringID string;
if (this->town->goal[i] == TOWN_GROWTH_DESERT || this->town->goal[i] == TOWN_GROWTH_WINTER) {
/* For 'original' gameplay, don't show the amount required (you need 1 or more ..) */
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL;
if (this->town->received[i].old_act == 0) {
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_GENERAL;
if (this->town->goal[i] == TOWN_GROWTH_WINTER && TileHeight(this->town->xy) < GetSnowLine()) {
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER;
}
}
SetDParam(0, cargo->name);
} else {
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED;
if (this->town->received[i].old_act < this->town->goal[i]) {
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED;
}
SetDParam(0, cargo->Index());
SetDParam(1, this->town->received[i].old_act);
SetDParam(2, cargo->Index());
SetDParam(3, this->town->goal[i]);
}
DrawString(cargo_text_left, cargo_text_right, y += FONT_HEIGHT_NORMAL, string);
}
if (HasBit(this->town->flags, TOWN_IS_GROWING)) {
SetDParam(0, RoundDivSU(this->town->growth_rate + 1, DAY_TICKS));
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, this->town->fund_buildings_months == 0 ? STR_TOWN_VIEW_TOWN_GROWS_EVERY : STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED);
} else {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_TOWN_GROW_STOPPED);
}
/* only show the town noise, if the noise option is activated. */
if (_settings_game.economy.station_noise_level) {
SetDParam(0, this->town->noise_reached);
SetDParam(1, this->town->MaxTownNoise());
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_NOISE_IN_TOWN);
}
if (this->town->text != NULL) {
SetDParamStr(0, this->town->text);
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y += FONT_HEIGHT_NORMAL, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
}
}
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case WID_TV_CENTER_VIEW: // scroll to location
if (_ctrl_pressed) {
ShowExtraViewPortWindow(this->town->xy);
} else {
ScrollMainWindowToTile(this->town->xy);
}
break;
case WID_TV_SHOW_AUTHORITY: // town authority
ShowTownAuthorityWindow(this->window_number);
break;
case WID_TV_CHANGE_NAME: // rename
SetDParam(0, this->window_number);
ShowQueryString(STR_TOWN_NAME, STR_TOWN_VIEW_RENAME_TOWN_BUTTON, MAX_LENGTH_TOWN_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
break;
case WID_TV_EXPAND: { // expand town - only available on Scenario editor
/* Warn the user if towns are not allowed to build roads, but do this only once per OpenTTD run. */
static bool _warn_town_no_roads = false;
if (!_settings_game.economy.allow_town_roads && !_warn_town_no_roads) {
ShowErrorMessage(STR_ERROR_TOWN_EXPAND_WARN_NO_ROADS, INVALID_STRING_ID, WL_WARNING);
_warn_town_no_roads = true;
}
DoCommandP(0, this->window_number, 0, CMD_EXPAND_TOWN | CMD_MSG(STR_ERROR_CAN_T_EXPAND_TOWN));
break;
}
case WID_TV_DELETE: // delete town - only available on Scenario editor
DoCommandP(0, this->window_number, 0, CMD_DELETE_TOWN | CMD_MSG(STR_ERROR_TOWN_CAN_T_DELETE));
break;
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
case WID_TV_INFO:
size->height = GetDesiredInfoHeight(size->width);
break;
}
}
/**
* Gets the desired height for the information panel.
* @return the desired height in pixels.
*/
uint GetDesiredInfoHeight(int width) const
{
uint aimed_height = 3 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
bool first = true;
for (int i = TE_BEGIN; i < TE_END; i++) {
if (this->town->goal[i] == 0) continue;
if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue;
if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;
if (first) {
aimed_height += FONT_HEIGHT_NORMAL;
first = false;
}
aimed_height += FONT_HEIGHT_NORMAL;
}
aimed_height += FONT_HEIGHT_NORMAL;
if (_settings_game.economy.station_noise_level) aimed_height += FONT_HEIGHT_NORMAL;
if (this->town->text != NULL) {
SetDParamStr(0, this->town->text);
aimed_height += GetStringHeight(STR_JUST_RAW_STRING, width - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT);
}
return aimed_height;
}
void ResizeWindowAsNeeded()
{
const NWidgetBase *nwid_info = this->GetWidget<NWidgetBase>(WID_TV_INFO);
uint aimed_height = GetDesiredInfoHeight(nwid_info->current_x);
if (aimed_height > nwid_info->current_y || (aimed_height < nwid_info->current_y && nwid_info->current_y > nwid_info->smallest_y)) {
this->ReInit();
}
}
virtual void OnResize()
{
if (this->viewport != NULL) {
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_TV_VIEWPORT);
nvp->UpdateViewportCoordinates(this);
ScrollWindowToTile(this->town->xy, this, true); // Re-center viewport.
}
}
/**
* 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.
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
if (!gui_scope) return;
/* Called when setting station noise or required cargoes have changed, in order to resize the window */
this->SetDirty(); // refresh display for current size. This will allow to avoid glitches when downgrading
this->ResizeWindowAsNeeded();
}
virtual void OnQueryTextFinished(char *str)
{
if (str == NULL) return;
DoCommandP(0, this->window_number, 0, CMD_RENAME_TOWN | CMD_MSG(STR_ERROR_CAN_T_RENAME_TOWN), NULL, str);
}
};
static const NWidgetPart _nested_town_game_view_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TV_CAPTION), SetDataTip(STR_TOWN_VIEW_TOWN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_BROWN),
NWidget(WWT_INSET, COLOUR_BROWN), SetPadding(2, 2, 2, 2),
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_TV_VIEWPORT), SetMinimalSize(254, 86), SetFill(1, 0), SetResize(1, 1), SetPadding(1, 1, 1, 1),
EndContainer(),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TV_INFO), SetMinimalSize(260, 32), SetResize(1, 0), SetFill(1, 0), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CENTER_VIEW), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_TOWN_VIEW_CENTER_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_SHOW_AUTHORITY), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON, STR_TOWN_VIEW_LOCAL_AUTHORITY_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP),
EndContainer(),
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
EndContainer(),
};
static WindowDesc _town_game_view_desc(
WDP_AUTO, "view_town", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
WC_TOWN_VIEW, WC_NONE,
0,
_nested_town_game_view_widgets, lengthof(_nested_town_game_view_widgets)
);
static const NWidgetPart _nested_town_editor_view_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TV_CAPTION), SetDataTip(STR_TOWN_VIEW_TOWN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(76, 14), SetDataTip(STR_BUTTON_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP),
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_BROWN),
NWidget(WWT_INSET, COLOUR_BROWN), SetPadding(2, 2, 2, 2),
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_TV_VIEWPORT), SetMinimalSize(254, 86), SetFill(1, 1), SetResize(1, 1), SetPadding(1, 1, 1, 1),
EndContainer(),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TV_INFO), SetMinimalSize(260, 32), SetResize(1, 0), SetFill(1, 0), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CENTER_VIEW), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_TOWN_VIEW_CENTER_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_EXPAND), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_EXPAND_BUTTON, STR_TOWN_VIEW_EXPAND_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_DELETE), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_DELETE_BUTTON, STR_TOWN_VIEW_DELETE_TOOLTIP),
EndContainer(),
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
EndContainer(),
};
static WindowDesc _town_editor_view_desc(
WDP_AUTO, "view_town_scen", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
WC_TOWN_VIEW, WC_NONE,
0,
_nested_town_editor_view_widgets, lengthof(_nested_town_editor_view_widgets)
);
void ShowTownViewWindow(TownID town)
{
if (_game_mode == GM_EDITOR) {
AllocateWindowDescFront<TownViewWindow>(&_town_editor_view_desc, town);
} else {
AllocateWindowDescFront<TownViewWindow>(&_town_game_view_desc, town);
}
}
static const NWidgetPart _nested_town_directory_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_TOWN_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_VERTICAL),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_TD_SORT_ORDER), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_TD_SORT_CRITERIA), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
NWidget(WWT_PANEL, COLOUR_BROWN), SetResize(1, 0), EndContainer(),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TD_LIST), SetMinimalSize(196, 0), SetDataTip(0x0, STR_TOWN_DIRECTORY_LIST_TOOLTIP),
SetFill(1, 0), SetResize(0, 10), SetScrollbar(WID_TD_SCROLLBAR), EndContainer(),
NWidget(WWT_PANEL, COLOUR_BROWN),
NWidget(WWT_TEXT, COLOUR_BROWN, WID_TD_WORLD_POPULATION), SetPadding(2, 0, 0, 2), SetMinimalSize(196, 12), SetFill(1, 0), SetDataTip(STR_TOWN_POPULATION, STR_NULL),
EndContainer(),
EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_TD_SCROLLBAR),
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
EndContainer(),
EndContainer(),
};
/** Town directory window class. */
struct TownDirectoryWindow : public Window {
private:
/* Runtime saved values */
static Listing last_sorting;
static const Town *last_town;
/* Constants for sorting towns */
static const StringID sorter_names[];
static GUITownList::SortFunction * const sorter_funcs[];
GUITownList towns;
Scrollbar *vscroll;
void BuildSortTownList()
{
if (this->towns.NeedRebuild()) {
this->towns.Clear();
const Town *t;
FOR_ALL_TOWNS(t) {
*this->towns.Append() = t;
}
this->towns.Compact();
this->towns.RebuildDone();
this->vscroll->SetCount(this->towns.Length()); // Update scrollbar as well.
}
/* Always sort the towns. */
this->last_town = NULL;
this->towns.Sort();
this->SetWidgetDirty(WID_TD_LIST); // Force repaint of the displayed towns.
}
/** Sort by town name */
static int CDECL TownNameSorter(const Town * const *a, const Town * const *b)
{
static char buf_cache[64];
const Town *ta = *a;
const Town *tb = *b;
char buf[64];
SetDParam(0, ta->index);
GetString(buf, STR_TOWN_NAME, lastof(buf));
/* If 'b' is the same town as in the last round, use the cached value
* We do this to speed stuff up ('b' is called with the same value a lot of
* times after each other) */
if (tb != last_town) {
last_town = tb;
SetDParam(0, tb->index);
GetString(buf_cache, STR_TOWN_NAME, lastof(buf_cache));
}
return strnatcmp(buf, buf_cache); // Sort by name (natural sorting).
}
/** Sort by population (default descending, as big towns are of the most interest). */
static int CDECL TownPopulationSorter(const Town * const *a, const Town * const *b)
{
uint32 a_population = (*a)->cache.population;
uint32 b_population = (*b)->cache.population;
if (a_population == b_population) return TownDirectoryWindow::TownNameSorter(a, b);
return (a_population < b_population) ? -1 : 1;
}
/** Sort by town rating */
static int CDECL TownRatingSorter(const Town * const *a, const Town * const *b)
{
int before = TownDirectoryWindow::last_sorting.order ? 1 : -1; // Value to get 'a' before 'b'.
/* Towns without rating are always after towns with rating. */
if (HasBit((*a)->have_ratings, _local_company)) {
if (HasBit((*b)->have_ratings, _local_company)) {
int16 a_rating = (*a)->ratings[_local_company];
int16 b_rating = (*b)->ratings[_local_company];
if (a_rating == b_rating) return TownDirectoryWindow::TownNameSorter(a, b);
return (a_rating < b_rating) ? -1 : 1;
}
return before;
}
if (HasBit((*b)->have_ratings, _local_company)) return -before;
return -before * TownDirectoryWindow::TownNameSorter(a, b); // Sort unrated towns always on ascending town name.
}
public:
TownDirectoryWindow(WindowDesc *desc) : Window(desc)
{
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_TD_SCROLLBAR);
this->towns.SetListing(this->last_sorting);
this->towns.SetSortFuncs(TownDirectoryWindow::sorter_funcs);
this->towns.ForceRebuild();
this->BuildSortTownList();
this->FinishInitNested(0);
}
virtual void SetStringParameters(int widget) const
{
switch (widget) {
case WID_TD_WORLD_POPULATION:
SetDParam(0, GetWorldPopulation());
break;
case WID_TD_SORT_CRITERIA:
SetDParam(0, TownDirectoryWindow::sorter_names[this->towns.SortType()]);
break;
}
}
/**
* Get the string to draw the town name.
* @param t Town to draw.
* @return The string to use.
*/
static StringID GetTownString(const Town *t)
{
return t->larger_town ? STR_TOWN_DIRECTORY_CITY : STR_TOWN_DIRECTORY_TOWN;
}
virtual void DrawWidget(const Rect &r, int widget) const
{
switch (widget) {
case WID_TD_SORT_ORDER:
this->DrawSortButtonState(widget, this->towns.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
break;
case WID_TD_LIST: {
int n = 0;
int y = r.top + WD_FRAMERECT_TOP;
if (this->towns.Length() == 0) { // No towns available.
DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y, STR_TOWN_DIRECTORY_NONE);
break;
}
/* At least one town available. */
bool rtl = _current_text_dir == TD_RTL;
Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
int text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : icon_size.width + 2);
int text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? icon_size.width + 2 : 0);
int icon_x = rtl ? r.right - WD_FRAMERECT_RIGHT - icon_size.width : r.left + WD_FRAMERECT_LEFT;
for (uint i = this->vscroll->GetPosition(); i < this->towns.Length(); i++) {
const Town *t = this->towns[i];
assert(t->xy != INVALID_TILE);
/* Draw rating icon. */
if (_game_mode == GM_EDITOR || !HasBit(t->have_ratings, _local_company)) {
DrawSprite(SPR_TOWN_RATING_NA, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
} else {
SpriteID icon = SPR_TOWN_RATING_APALLING;
if (t->ratings[_local_company] > RATING_VERYPOOR) icon = SPR_TOWN_RATING_MEDIOCRE;
if (t->ratings[_local_company] > RATING_GOOD) icon = SPR_TOWN_RATING_GOOD;
DrawSprite(icon, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
}
SetDParam(0, t->index);
SetDParam(1, t->cache.population);
DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, GetTownString(t));
y += this->resize.step_height;
if (++n == this->vscroll->GetCapacity()) break; // max number of towns in 1 window
}
break;
}
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
case WID_TD_SORT_ORDER: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height;
*size = maxdim(*size, d);
break;
}
case WID_TD_SORT_CRITERIA: {
Dimension d = {0, 0};
for (uint i = 0; TownDirectoryWindow::sorter_names[i] != INVALID_STRING_ID; i++) {
d = maxdim(d, GetStringBoundingBox(TownDirectoryWindow::sorter_names[i]));
}
d.width += padding.width;
d.height += padding.height;
*size = maxdim(*size, d);
break;
}
case WID_TD_LIST: {
Dimension d = GetStringBoundingBox(STR_TOWN_DIRECTORY_NONE);
for (uint i = 0; i < this->towns.Length(); i++) {
const Town *t = this->towns[i];
assert(t != NULL);
SetDParam(0, t->index);
SetDParamMaxDigits(1, 8);
d = maxdim(d, GetStringBoundingBox(GetTownString(t)));
}
Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
d.width += icon_size.width + 2;
d.height = max(d.height, icon_size.height);
resize->height = d.height;
d.height *= 5;
d.width += padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
*size = maxdim(*size, d);
break;
}
case WID_TD_WORLD_POPULATION: {
SetDParamMaxDigits(0, 10);
Dimension d = GetStringBoundingBox(STR_TOWN_POPULATION);
d.width += padding.width;
d.height += padding.height;
*size = maxdim(*size, d);
break;
}
}
}
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case WID_TD_SORT_ORDER: // Click on sort order button
if (this->towns.SortType() != 2) { // A different sort than by rating.
this->towns.ToggleSortOrder();
this->last_sorting = this->towns.GetListing(); // Store new sorting order.
} else {
/* Some parts are always sorted ascending on name. */
this->last_sorting.order = !this->last_sorting.order;
this->towns.SetListing(this->last_sorting);
this->towns.ForceResort();
this->towns.Sort();
}
this->SetDirty();
break;
case WID_TD_SORT_CRITERIA: // Click on sort criteria dropdown
ShowDropDownMenu(this, TownDirectoryWindow::sorter_names, this->towns.SortType(), WID_TD_SORT_CRITERIA, 0, 0);
break;
case WID_TD_LIST: { // Click on Town Matrix
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TD_LIST, WD_FRAMERECT_TOP);
if (id_v >= this->towns.Length()) return; // click out of town bounds
const Town *t = this->towns[id_v];
assert(t != NULL);
if (_ctrl_pressed) {
ShowExtraViewPortWindow(t->xy);
} else {
ScrollMainWindowToTile(t->xy);
}
break;
}
}
}
virtual void OnDropdownSelect(int widget, int index)
{
if (widget != WID_TD_SORT_CRITERIA) return;
if (this->towns.SortType() != index) {
this->towns.SetSortType(index);
this->last_sorting = this->towns.GetListing(); // Store new sorting order.
this->BuildSortTownList();
}
}
virtual void OnPaint()
{
if (this->towns.NeedRebuild()) this->BuildSortTownList();
this->DrawWidgets();
}
virtual void OnHundredthTick()
{
this->BuildSortTownList();
this->SetDirty();
}
virtual void OnResize()
{
this->vscroll->SetCapacityFromWidget(this, WID_TD_LIST);
}
/**
* 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.
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
if (data == 0) {
/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
this->towns.ForceRebuild();
} else {
this->towns.ForceResort();
}
}
};
Listing TownDirectoryWindow::last_sorting = {false, 0};
const Town *TownDirectoryWindow::last_town = NULL;
/** Names of the sorting functions. */
const StringID TownDirectoryWindow::sorter_names[] = {
STR_SORT_BY_NAME,
STR_SORT_BY_POPULATION,
STR_SORT_BY_RATING,
INVALID_STRING_ID
};
/** Available town directory sorting functions. */
GUITownList::SortFunction * const TownDirectoryWindow::sorter_funcs[] = {
&TownNameSorter,
&TownPopulationSorter,
&TownRatingSorter,
};
static WindowDesc _town_directory_desc(
WDP_AUTO, "list_towns", 208, 202,
WC_TOWN_DIRECTORY, WC_NONE,
0,
_nested_town_directory_widgets, lengthof(_nested_town_directory_widgets)
);
void ShowTownDirectory()
{
if (BringWindowToFrontById(WC_TOWN_DIRECTORY, 0)) return;
new TownDirectoryWindow(&_town_directory_desc);
}
void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy);
}
static const NWidgetPart _nested_found_town_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_FOUND_TOWN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
/* Construct new town(s) buttons. */
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
NWidget(NWID_SPACER), SetMinimalSize(0, 2),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_NEW_TOWN), SetMinimalSize(156, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_NEW_TOWN_BUTTON, STR_FOUND_TOWN_NEW_TOWN_TOOLTIP), SetPadding(0, 2, 1, 2),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_RANDOM_TOWN), SetMinimalSize(156, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_RANDOM_TOWN_BUTTON, STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP), SetPadding(0, 2, 1, 2),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_MANY_RANDOM_TOWNS), SetMinimalSize(156, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP), SetPadding(0, 2, 0, 2),
/* Town name selection. */
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(156, 14), SetPadding(0, 2, 0, 2), SetDataTip(STR_FOUND_TOWN_NAME_TITLE, STR_NULL),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_TF_TOWN_NAME_EDITBOX), SetMinimalSize(156, 12), SetPadding(0, 2, 3, 2),
SetDataTip(STR_FOUND_TOWN_NAME_EDITOR_TITLE, STR_FOUND_TOWN_NAME_EDITOR_HELP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_TOWN_NAME_RANDOM), SetMinimalSize(78, 12), SetPadding(0, 2, 0, 2), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_NAME_RANDOM_BUTTON, STR_FOUND_TOWN_NAME_RANDOM_TOOLTIP),
/* Town size selection. */
NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
NWidget(NWID_SPACER), SetFill(1, 0),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(148, 14), SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_TITLE, STR_NULL),
NWidget(NWID_SPACER), SetFill(1, 0),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(2, 0, 2),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_SIZE_SMALL), SetMinimalSize(78, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_SMALL_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_SIZE_MEDIUM), SetMinimalSize(78, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_MEDIUM_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(2, 0, 2),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_SIZE_LARGE), SetMinimalSize(78, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_LARGE_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_SIZE_RANDOM), SetMinimalSize(78, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_SIZE_RANDOM, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_CITY), SetPadding(0, 2, 0, 2), SetMinimalSize(156, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_CITY, STR_FOUND_TOWN_CITY_TOOLTIP), SetFill(1, 0),
/* Town roads selection. */
NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
NWidget(NWID_SPACER), SetFill(1, 0),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(148, 14), SetDataTip(STR_FOUND_TOWN_ROAD_LAYOUT, STR_NULL),
NWidget(NWID_SPACER), SetFill(1, 0),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(2, 0, 2),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_ORIGINAL), SetMinimalSize(78, 12), SetFill(1, 0), SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_ORIGINAL, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_BETTER), SetMinimalSize(78, 12), SetFill(1, 0), SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_BETTER_ROADS, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(2, 0, 2),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_GRID2), SetMinimalSize(78, 12), SetFill(1, 0), SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_2X2_GRID, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_GRID3), SetMinimalSize(78, 12), SetFill(1, 0), SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_3X3_GRID, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_RANDOM), SetPadding(0, 2, 0, 2), SetMinimalSize(0, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_RANDOM, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT), SetFill(1, 0),
NWidget(NWID_SPACER), SetMinimalSize(0, 2),
EndContainer(),
};
/** Found a town window class. */
struct FoundTownWindow : Window {
private:
TownSize town_size; ///< Selected town size
TownLayout town_layout; ///< Selected town layout
bool city; ///< Are we building a city?
QueryString townname_editbox; ///< Townname editbox
bool townnamevalid; ///< Is generated town name valid?
uint32 townnameparts; ///< Generated town name
TownNameParams params; ///< Town name parameters
public:
FoundTownWindow(WindowDesc *desc, WindowNumber window_number) :
Window(desc),
town_size(TSZ_MEDIUM),
town_layout(_settings_game.economy.town_layout),
townname_editbox(MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_TOWN_NAME_CHARS),
params(_settings_game.game_creation.town_name)
{
this->InitNested(window_number);
this->querystrings[WID_TF_TOWN_NAME_EDITBOX] = &this->townname_editbox;
this->RandomTownName();
this->UpdateButtons(true);
}
void RandomTownName()
{
this->townnamevalid = GenerateTownName(&this->townnameparts);
if (!this->townnamevalid) {
this->townname_editbox.text.DeleteAll();
} else {
GetTownName(this->townname_editbox.text.buf, &this->params, this->townnameparts, &this->townname_editbox.text.buf[this->townname_editbox.text.max_bytes - 1]);
this->townname_editbox.text.UpdateSize();
}
UpdateOSKOriginalText(this, WID_TF_TOWN_NAME_EDITBOX);
this->SetWidgetDirty(WID_TF_TOWN_NAME_EDITBOX);
}
void UpdateButtons(bool check_availability)
{
if (check_availability && _game_mode != GM_EDITOR) {
this->SetWidgetsDisabledState(true, WID_TF_RANDOM_TOWN, WID_TF_MANY_RANDOM_TOWNS, WID_TF_SIZE_LARGE, WIDGET_LIST_END);
this->SetWidgetsDisabledState(_settings_game.economy.found_town != TF_CUSTOM_LAYOUT,
WID_TF_LAYOUT_ORIGINAL, WID_TF_LAYOUT_BETTER, WID_TF_LAYOUT_GRID2, WID_TF_LAYOUT_GRID3, WID_TF_LAYOUT_RANDOM, WIDGET_LIST_END);
if (_settings_game.economy.found_town != TF_CUSTOM_LAYOUT) town_layout = _settings_game.economy.town_layout;
}
for (int i = WID_TF_SIZE_SMALL; i <= WID_TF_SIZE_RANDOM; i++) {
this->SetWidgetLoweredState(i, i == WID_TF_SIZE_SMALL + this->town_size);
}
this->SetWidgetLoweredState(WID_TF_CITY, this->city);
for (int i = WID_TF_LAYOUT_ORIGINAL; i <= WID_TF_LAYOUT_RANDOM; i++) {
this->SetWidgetLoweredState(i, i == WID_TF_LAYOUT_ORIGINAL + this->town_layout);
}
this->SetDirty();
}
void ExecuteFoundTownCommand(TileIndex tile, bool random, StringID errstr, CommandCallback cc)
{
const char *name = NULL;
if (!this->townnamevalid) {
name = this->townname_editbox.text.buf;
} else {
/* If user changed the name, send it */
char buf[MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH];
GetTownName(buf, &this->params, this->townnameparts, lastof(buf));
if (strcmp(buf, this->townname_editbox.text.buf) != 0) name = this->townname_editbox.text.buf;
}
bool success = DoCommandP(tile, this->town_size | this->city << 2 | this->town_layout << 3 | random << 6,
townnameparts, CMD_FOUND_TOWN | CMD_MSG(errstr), cc, name);
/* Rerandomise name, if success and no cost-estimation. */
if (success && !_shift_pressed) this->RandomTownName();
}
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case WID_TF_NEW_TOWN:
HandlePlacePushButton(this, WID_TF_NEW_TOWN, SPR_CURSOR_TOWN, HT_RECT);
break;
case WID_TF_RANDOM_TOWN:
this->ExecuteFoundTownCommand(0, true, STR_ERROR_CAN_T_GENERATE_TOWN, CcFoundRandomTown);
break;
case WID_TF_TOWN_NAME_RANDOM:
this->RandomTownName();
this->SetFocusedWidget(WID_TF_TOWN_NAME_EDITBOX);
break;
case WID_TF_MANY_RANDOM_TOWNS:
_generating_world = true;
UpdateNearestTownForRoadTiles(true);
if (!GenerateTowns(this->town_layout)) {
ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_TOWN, STR_ERROR_NO_SPACE_FOR_TOWN, WL_INFO);
}
UpdateNearestTownForRoadTiles(false);
_generating_world = false;
break;
case WID_TF_SIZE_SMALL: case WID_TF_SIZE_MEDIUM: case WID_TF_SIZE_LARGE: case WID_TF_SIZE_RANDOM:
this->town_size = (TownSize)(widget - WID_TF_SIZE_SMALL);
this->UpdateButtons(false);
break;
case WID_TF_CITY:
this->city ^= true;
this->SetWidgetLoweredState(WID_TF_CITY, this->city);
this->SetDirty();
break;
case WID_TF_LAYOUT_ORIGINAL: case WID_TF_LAYOUT_BETTER: case WID_TF_LAYOUT_GRID2:
case WID_TF_LAYOUT_GRID3: case WID_TF_LAYOUT_RANDOM:
this->town_layout = (TownLayout)(widget - WID_TF_LAYOUT_ORIGINAL);
this->UpdateButtons(false);
break;
}
}
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
this->ExecuteFoundTownCommand(tile, false, STR_ERROR_CAN_T_FOUND_TOWN_HERE, CcFoundTown);
}
virtual void OnPlaceObjectAbort()
{
this->RaiseButtons();
this->UpdateButtons(false);
}
/**
* 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.
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
if (!gui_scope) return;
this->UpdateButtons(true);
}
};
static WindowDesc _found_town_desc(
WDP_AUTO, "build_town", 160, 162,
WC_FOUND_TOWN, WC_NONE,
WDF_CONSTRUCTION,
_nested_found_town_widgets, lengthof(_nested_found_town_widgets)
);
void ShowFoundTownWindow()
{
if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return;
AllocateWindowDescFront<FoundTownWindow>(&_found_town_desc, 0);
}
|