Files @ r28575:8bbb27103bfb
Branch filter:

Location: cpp/openttd-patchpack/source/src/signs_gui.cpp - annotation

Patric Stout
Fix: update server as offline when unexpected disconnect during refresh (#11891)
  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
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r9111:983de9c5a848
r6420:01087f989fd1
r5751:9b4f4afbf71b
r10208:ef8fcc3dc4ca
r10208:ef8fcc3dc4ca
r8790:550c9960067a
r8790:550c9960067a
r5751:9b4f4afbf71b
r8116:df67d3c5e4fd
r8114:866ed489ed98
r8131:7a50db7be0ff
r8139:4fc34c1bc2fb
r8224:194097dc7288
r9179:660680ae613d
r9734:a275a2ebaa53
r19420:97b6814a3b2f
r10087:330fdda1e960
r14248:a9050881acd7
r15827:4bfb4849cb26
r17894:3efa365a1d98
r24647:35d23833519f
r26103:316b73a1be08
r27089:0c098eaacf35
r27089:0c098eaacf35
r5751:9b4f4afbf71b
r18670:f122c356353c
r18670:f122c356353c
r8264:d493cb51fe8a
r12915:72cc86ee5e3b
r8264:d493cb51fe8a
r21383:942c32fb8b0e
r21383:942c32fb8b0e
r9734:a275a2ebaa53
r15827:4bfb4849cb26
r19420:97b6814a3b2f
r15827:4bfb4849cb26
r28236:3864664b5c22
r5751:9b4f4afbf71b
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r19420:97b6814a3b2f
r16672:c10913372b81
r27193:e816892ba57b
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r19420:97b6814a3b2f
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r5751:9b4f4afbf71b
r25655:1030dcb7eb52
r9734:a275a2ebaa53
r23517:1a32c3c14728
r5751:9b4f4afbf71b
r23970:272c50d4cd26
r5751:9b4f4afbf71b
r18763:938cba34d55a
r15827:4bfb4849cb26
r23518:3531e6987951
r9734:a275a2ebaa53
r5751:9b4f4afbf71b
r5751:9b4f4afbf71b
r9734:a275a2ebaa53
r23613:a3dc001d74fb
r9734:a275a2ebaa53
r23377:8ad8aa4571c6
r23377:8ad8aa4571c6
r23377:8ad8aa4571c6
r23377:8ad8aa4571c6
r27193:e816892ba57b
r27193:e816892ba57b
r5751:9b4f4afbf71b
r27193:e816892ba57b
r15356:3504763440ee
r23613:a3dc001d74fb
r9734:a275a2ebaa53
r5751:9b4f4afbf71b
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r15827:4bfb4849cb26
r19420:97b6814a3b2f
r19420:97b6814a3b2f
r15827:4bfb4849cb26
r23377:8ad8aa4571c6
r27193:e816892ba57b
r15827:4bfb4849cb26
r19420:97b6814a3b2f
r27585:ba57a9a2dd40
r19420:97b6814a3b2f
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r18763:938cba34d55a
r27942:f7389062d120
r18763:938cba34d55a
r18763:938cba34d55a
r18763:938cba34d55a
r18763:938cba34d55a
r18763:938cba34d55a
r17894:3efa365a1d98
r27942:f7389062d120
r17894:3efa365a1d98
r17894:3efa365a1d98
r17894:3efa365a1d98
r19075:246e5349e935
r17894:3efa365a1d98
r17894:3efa365a1d98
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r19420:97b6814a3b2f
r19420:97b6814a3b2f
r17894:3efa365a1d98
r19420:97b6814a3b2f
r17894:3efa365a1d98
r15827:4bfb4849cb26
r9734:a275a2ebaa53
r5751:9b4f4afbf71b
r15827:4bfb4849cb26
r27193:e816892ba57b
r5751:9b4f4afbf71b
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r11517:28b32f467232
r11517:28b32f467232
r19787:20d2473dd1cb
r19787:20d2473dd1cb
r18693:c50955706bdd
r15769:4a935f419828
r12915:72cc86ee5e3b
r20280:ca1fc41725ff
r9316:61233b01525f
r20280:ca1fc41725ff
r18693:c50955706bdd
r20280:ca1fc41725ff
r18693:c50955706bdd
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r19787:20d2473dd1cb
r19788:5fba5abdb946
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r9734:a275a2ebaa53
r12915:72cc86ee5e3b
r17463:0e77af810a2d
r9316:61233b01525f
r5751:9b4f4afbf71b
r23499:f9bf6ad58697
r23377:8ad8aa4571c6
r23607:36c15679007d
r27193:e816892ba57b
r23377:8ad8aa4571c6
r23377:8ad8aa4571c6
r23377:8ad8aa4571c6
r23377:8ad8aa4571c6
r23377:8ad8aa4571c6
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r19420:97b6814a3b2f
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r23499:f9bf6ad58697
r9316:61233b01525f
r23377:8ad8aa4571c6
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r9316:61233b01525f
r28353:bfc4ab63f376
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r18693:c50955706bdd
r26575:d5725bf82346
r28167:b14ea36d49e5
r12915:72cc86ee5e3b
r15769:4a935f419828
r26549:82dacf005b0a
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r5751:9b4f4afbf71b
r25333:f3bf51cfa952
r16431:ec558deca9d7
r25333:f3bf51cfa952
r26549:82dacf005b0a
r26549:82dacf005b0a
r13640:7bf2820205ed
r12915:72cc86ee5e3b
r27737:728d55b97775
r26575:d5725bf82346
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r26549:82dacf005b0a
r5751:9b4f4afbf71b
r12915:72cc86ee5e3b
r26549:82dacf005b0a
r26549:82dacf005b0a
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r9316:61233b01525f
r28353:bfc4ab63f376
r12915:72cc86ee5e3b
r18693:c50955706bdd
r9316:61233b01525f
r5751:9b4f4afbf71b
r28353:bfc4ab63f376
r9316:61233b01525f
r15827:4bfb4849cb26
r18693:c50955706bdd
r27334:5391a05e2771
r27334:5391a05e2771
r5751:9b4f4afbf71b
r27334:5391a05e2771
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r19777:9fe4698602ed
r19777:9fe4698602ed
r23520:20bbc807b0eb
r19777:9fe4698602ed
r19777:9fe4698602ed
r19777:9fe4698602ed
r19777:9fe4698602ed
r19777:9fe4698602ed
r18693:c50955706bdd
r15827:4bfb4849cb26
r18693:c50955706bdd
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r9316:61233b01525f
r9316:61233b01525f
r5751:9b4f4afbf71b
r23499:f9bf6ad58697
r9316:61233b01525f
r26575:d5725bf82346
r12915:72cc86ee5e3b
r12915:72cc86ee5e3b
r28353:bfc4ab63f376
r12915:72cc86ee5e3b
r13687:2fe781e89e93
r18693:c50955706bdd
r13687:2fe781e89e93
r26575:d5725bf82346
r28167:b14ea36d49e5
r26575:d5725bf82346
r13687:2fe781e89e93
r15608:7b580ec7448a
r15608:7b580ec7448a
r13687:2fe781e89e93
r18693:c50955706bdd
r19846:75a27628493b
r13687:2fe781e89e93
r13687:2fe781e89e93
r13687:2fe781e89e93
r13687:2fe781e89e93
r12919:f93f5a75e6b3
r5751:9b4f4afbf71b
r9734:a275a2ebaa53
r23499:f9bf6ad58697
r15827:4bfb4849cb26
r20399:ead82fb894d7
r20399:ead82fb894d7
r20399:ead82fb894d7
r20399:ead82fb894d7
r20399:ead82fb894d7
r20399:ead82fb894d7
r20399:ead82fb894d7
r20399:ead82fb894d7
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r20399:ead82fb894d7
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r28353:bfc4ab63f376
r15827:4bfb4849cb26
r19787:20d2473dd1cb
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r17463:0e77af810a2d
r17463:0e77af810a2d
r17463:0e77af810a2d
r17463:0e77af810a2d
r27278:7b609c53d377
r18693:c50955706bdd
r17463:0e77af810a2d
r17463:0e77af810a2d
r17463:0e77af810a2d
r17463:0e77af810a2d
r27089:0c098eaacf35
r27089:0c098eaacf35
r17463:0e77af810a2d
r17463:0e77af810a2d
r27089:0c098eaacf35
r15827:4bfb4849cb26
r17476:d3b7a183536d
r17476:d3b7a183536d
r17476:d3b7a183536d
r17476:d3b7a183536d
r17476:d3b7a183536d
r27942:f7389062d120
r9734:a275a2ebaa53
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r17482:4dbb8b190ff9
r19420:97b6814a3b2f
r17482:4dbb8b190ff9
r9734:a275a2ebaa53
r15827:4bfb4849cb26
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r15827:4bfb4849cb26
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r5751:9b4f4afbf71b
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r27524:9bc6967f2b31
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r28487:2130fff7270c
r11759:1bee7958ff4d
r25039:1deb621cd116
r25039:1deb621cd116
r25039:1deb621cd116
r25039:1deb621cd116
r25039:1deb621cd116
r11759:1bee7958ff4d
r11759:1bee7958ff4d
r11759:1bee7958ff4d
r26575:d5725bf82346
r25333:f3bf51cfa952
r15827:4bfb4849cb26
r25039:1deb621cd116
r25039:1deb621cd116
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r25039:1deb621cd116
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r28093:10ddf6ea3097
r25039:1deb621cd116
r11759:1bee7958ff4d
r11759:1bee7958ff4d
r11759:1bee7958ff4d
r11759:1bee7958ff4d
r28078:5e5d6c0447b1
r20283:2a199c78224c
r5893:6c4fd9987e0f
r19745:d8f95208ad9e
r27861:6269475166e0
r20399:ead82fb894d7
r11368:058349c3a02c
r5751:9b4f4afbf71b
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r23607:36c15679007d
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r15827:4bfb4849cb26
r5751:9b4f4afbf71b
r10182:13ce7c8953d0
r10182:13ce7c8953d0
r10182:13ce7c8953d0
r10182:13ce7c8953d0
r10182:13ce7c8953d0
r10182:13ce7c8953d0
r10182:13ce7c8953d0
r9179:660680ae613d
r10182:13ce7c8953d0
r26119:a6e64747fa5d
r10182:13ce7c8953d0
r9179:660680ae613d
r7127:9394e882dc36
r19787:20d2473dd1cb
r19787:20d2473dd1cb
r9179:660680ae613d
r7127:9394e882dc36
r20280:ca1fc41725ff
r9179:660680ae613d
r19787:20d2473dd1cb
r19787:20d2473dd1cb
r19787:20d2473dd1cb
r19787:20d2473dd1cb
r13147:103cec70ab90
r20280:ca1fc41725ff
r13147:103cec70ab90
r9179:660680ae613d
r18693:c50955706bdd
r9179:660680ae613d
r9179:660680ae613d
r9179:660680ae613d
r9179:660680ae613d
r19944:25a78576fb5e
r24214:a65c412aafcc
r9179:660680ae613d
r19787:20d2473dd1cb
r9179:660680ae613d
r19787:20d2473dd1cb
r9179:660680ae613d
r7127:9394e882dc36
r9179:660680ae613d
r9179:660680ae613d
r18693:c50955706bdd
r18693:c50955706bdd
r9179:660680ae613d
r7127:9394e882dc36
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r23553:9f01781fc43d
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r10157:85398815e83e
r23520:20bbc807b0eb
r10157:85398815e83e
r10157:85398815e83e
r28353:bfc4ab63f376
r13147:103cec70ab90
r13147:103cec70ab90
r18693:c50955706bdd
r19787:20d2473dd1cb
r13147:103cec70ab90
r13147:103cec70ab90
r13147:103cec70ab90
r13147:103cec70ab90
r28353:bfc4ab63f376
r9179:660680ae613d
r9179:660680ae613d
r24647:35d23833519f
r24647:35d23833519f
r24647:35d23833519f
r24647:35d23833519f
r24647:35d23833519f
r24647:35d23833519f
r24647:35d23833519f
r24647:35d23833519f
r24647:35d23833519f
r24647:35d23833519f
r24647:35d23833519f
r18693:c50955706bdd
r18693:c50955706bdd
r18693:c50955706bdd
r10157:85398815e83e
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r9179:660680ae613d
r9179:660680ae613d
r9179:660680ae613d
r9734:a275a2ebaa53
r9734:a275a2ebaa53
r7127:9394e882dc36
r18693:c50955706bdd
r9179:660680ae613d
r10156:5d97c842d2d7
r10156:5d97c842d2d7
r10156:5d97c842d2d7
r7127:9394e882dc36
r18693:c50955706bdd
r19787:20d2473dd1cb
r22672:3473f7daf422
r7127:9394e882dc36
r18693:c50955706bdd
r25564:c875d92c537a
r9179:660680ae613d
r9179:660680ae613d
r9179:660680ae613d
r9179:660680ae613d
r7127:9394e882dc36
r28487:2130fff7270c
r11759:1bee7958ff4d
r13742:180ad925befc
r27245:43b55d4c0b1f
r24647:35d23833519f
r11759:1bee7958ff4d
r13745:49505a0400d8
r18693:c50955706bdd
r11759:1bee7958ff4d
r11759:1bee7958ff4d
r18693:c50955706bdd
r18693:c50955706bdd
r18693:c50955706bdd
r13745:49505a0400d8
r18693:c50955706bdd
r18693:c50955706bdd
r11759:1bee7958ff4d
r11759:1bee7958ff4d
r11759:1bee7958ff4d
r28078:5e5d6c0447b1
r27724:fe6470f73b2e
r7127:9394e882dc36
r19745:d8f95208ad9e
r27861:6269475166e0
r11368:058349c3a02c
r7127:9394e882dc36
r17625:366001a31c88
r17625:366001a31c88
r17625:366001a31c88
r17625:366001a31c88
r9510:6d2f1c62ff65
r9510:6d2f1c62ff65
r26082:ed4b80b7fdde
r26082:ed4b80b7fdde
r26082:ed4b80b7fdde
r19075:246e5349e935
r25606:f5a35e979802
r9510:6d2f1c62ff65
r9510:6d2f1c62ff65
r26082:ed4b80b7fdde
r9510:6d2f1c62ff65
r9510:6d2f1c62ff65
r9510:6d2f1c62ff65
r17625:366001a31c88
r17625:366001a31c88
r17625:366001a31c88
r17625:366001a31c88
r7127:9394e882dc36
r7127:9394e882dc36
r11081:725ce4237987
r25565:6a5de7df7ea1
r7127:9394e882dc36
r9179:660680ae613d
r7127:9394e882dc36
r10156:5d97c842d2d7
r17625:366001a31c88
r17625:366001a31c88
r17625:366001a31c88
r17625:366001a31c88
r10156:5d97c842d2d7
r10156:5d97c842d2d7
r18743:bbdd9a165607
r10156:5d97c842d2d7
r25564:c875d92c537a
r10156:5d97c842d2d7
/*
 * 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 signs_gui.cpp The GUI for signs. */

#include "stdafx.h"
#include "company_gui.h"
#include "company_func.h"
#include "signs_base.h"
#include "signs_func.h"
#include "debug.h"
#include "command_func.h"
#include "strings_func.h"
#include "window_func.h"
#include "map_func.h"
#include "viewport_func.h"
#include "querystring_gui.h"
#include "sortlist_type.h"
#include "stringfilter_type.h"
#include "string_func.h"
#include "core/geometry_func.hpp"
#include "hotkeys.h"
#include "transparency.h"
#include "gui.h"
#include "signs_cmd.h"
#include "timer/timer.h"
#include "timer/timer_window.h"

#include "widgets/sign_widget.h"

#include "table/strings.h"
#include "table/sprites.h"

#include "safeguards.h"

struct SignList {
	/**
	 * A GUIList contains signs and uses a StringFilter for filtering.
	 */
	typedef GUIList<const Sign *, std::nullptr_t, StringFilter &> GUISignList;

	GUISignList signs;

	StringFilter string_filter;                                       ///< The match string to be used when the GUIList is (re)-sorted.
	static bool match_case;                                           ///< Should case sensitive matching be used?
	static std::string default_name;                                  ///< Default sign name, used if Sign::name is nullptr.

	/**
	 * Creates a SignList with filtering disabled by default.
	 */
	SignList() : string_filter(&match_case)
	{
	}

	void BuildSignsList()
	{
		if (!this->signs.NeedRebuild()) return;

		Debug(misc, 3, "Building sign list");

		this->signs.clear();

		for (const Sign *si : Sign::Iterate()) this->signs.push_back(si);

		this->signs.SetFilterState(true);
		this->FilterSignList();
		this->signs.shrink_to_fit();
		this->signs.RebuildDone();
	}

	/** Sort signs by their name */
	static bool SignNameSorter(const Sign * const &a, const Sign * const &b)
	{
		/* Signs are very very rarely using the default text, but there can also be
		 * a lot of them. Therefore a worthwhile performance gain can be made by
		 * directly comparing Sign::name instead of going through the string
		 * system for each comparison. */
		const std::string &a_name = a->name.empty() ? SignList::default_name : a->name;
		const std::string &b_name = b->name.empty() ? SignList::default_name : b->name;

		int r = StrNaturalCompare(a_name, b_name); // Sort by name (natural sorting).

		return r != 0 ? r < 0 : (a->index < b->index);
	}

	void SortSignsList()
	{
		if (!this->signs.Sort(&SignNameSorter)) return;
	}

	/** Filter sign list by sign name */
	static bool CDECL SignNameFilter(const Sign * const *a, StringFilter &filter)
	{
		/* Same performance benefit as above for sorting. */
		const std::string &a_name = (*a)->name.empty() ? SignList::default_name : (*a)->name;

		filter.ResetState();
		filter.AddLine(a_name);
		return filter.GetState();
	}

	/** Filter sign list excluding OWNER_DEITY */
	static bool CDECL OwnerDeityFilter(const Sign * const *a, StringFilter &)
	{
		/* You should never be able to edit signs of owner DEITY */
		return (*a)->owner != OWNER_DEITY;
	}

	/** Filter sign list by owner */
	static bool CDECL OwnerVisibilityFilter(const Sign * const *a, StringFilter &)
	{
		assert(!HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS));
		/* Hide sign if non-own signs are hidden in the viewport */
		return (*a)->owner == _local_company || (*a)->owner == OWNER_DEITY;
	}

	/** Filter out signs from the sign list that does not match the name filter */
	void FilterSignList()
	{
		this->signs.Filter(&SignNameFilter, this->string_filter);
		if (_game_mode != GM_EDITOR) this->signs.Filter(&OwnerDeityFilter, this->string_filter);
		if (!HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)) {
			this->signs.Filter(&OwnerVisibilityFilter, this->string_filter);
		}
	}
};

bool SignList::match_case = false;
std::string SignList::default_name;

/** Enum referring to the Hotkeys in the sign list window */
enum SignListHotkeys {
	SLHK_FOCUS_FILTER_BOX, ///< Focus the edit box for editing the filter string
};

struct SignListWindow : Window, SignList {
	QueryString filter_editbox; ///< Filter editbox;
	int text_offset; ///< Offset of the sign text relative to the left edge of the WID_SIL_LIST widget.
	Scrollbar *vscroll;

	SignListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), filter_editbox(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS)
	{
		this->CreateNestedTree();
		this->vscroll = this->GetScrollbar(WID_SIL_SCROLLBAR);
		this->FinishInitNested(window_number);
		this->SetWidgetLoweredState(WID_SIL_FILTER_MATCH_CASE_BTN, SignList::match_case);

		/* Initialize the text edit widget */
		this->querystrings[WID_SIL_FILTER_TEXT] = &this->filter_editbox;
		this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;

		/* Initialize the filtering variables */
		this->SetFilterString("");

		/* Create initial list. */
		this->signs.ForceRebuild();
		this->signs.ForceResort();
		this->BuildSortSignList();
	}

	void OnInit() override
	{
		/* Default sign name, used if Sign::name is nullptr. */
		SignList::default_name = GetString(STR_DEFAULT_SIGN_NAME);
		this->signs.ForceResort();
		this->SortSignsList();
		this->SetDirty();
	}

	/**
	 * This function sets the filter string of the sign list. The contents of
	 * the edit widget is not updated by this function. Depending on if the
	 * new string is zero-length or not the clear button is made
	 * disabled/enabled. The sign list is updated according to the new filter.
	 */
	void SetFilterString(const char *new_filter_string)
	{
		/* check if there is a new filter string */
		this->string_filter.SetFilterTerm(new_filter_string);

		/* Rebuild the list of signs */
		this->InvalidateData();
	}

	void OnPaint() override
	{
		if (!this->IsShaded() && this->signs.NeedRebuild()) this->BuildSortSignList();
		this->DrawWidgets();
	}

	void DrawWidget(const Rect &r, WidgetID widget) const override
	{
		switch (widget) {
			case WID_SIL_LIST: {
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
				uint text_offset_y = (this->resize.step_height - GetCharacterHeight(FS_NORMAL) + 1) / 2;
				/* No signs? */
				if (this->vscroll->GetCount() == 0) {
					DrawString(tr.left, tr.right, tr.top + text_offset_y, STR_STATION_LIST_NONE);
					return;
				}

				Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
				bool rtl = _current_text_dir == TD_RTL;
				int sprite_offset_y = (this->resize.step_height - d.height + 1) / 2;
				uint icon_left = rtl ? tr.right - this->text_offset : tr.left;
				tr = tr.Indent(this->text_offset, rtl);

				/* At least one sign available. */
				for (uint16_t i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++)
				{
					const Sign *si = this->signs[i];

					if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, tr.top + sprite_offset_y);

					SetDParam(0, si->index);
					DrawString(tr.left, tr.right, tr.top + text_offset_y, STR_SIGN_NAME, TC_YELLOW);
					tr.top += this->resize.step_height;
				}
				break;
			}
		}
	}

	void SetStringParameters(WidgetID widget) const override
	{
		if (widget == WID_SIL_CAPTION) SetDParam(0, this->vscroll->GetCount());
	}

	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
	{
		switch (widget) {
			case WID_SIL_LIST: {
				auto it = this->vscroll->GetScrolledItemFromWidget(this->signs, pt.y, this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.top);
				if (it == this->signs.end()) return;

				const Sign *si = *it;
				ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
				break;
			}

			case WID_SIL_FILTER_ENTER_BTN:
				if (this->signs.size() >= 1) {
					const Sign *si = this->signs[0];
					ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
				}
				break;

			case WID_SIL_FILTER_MATCH_CASE_BTN:
				SignList::match_case = !SignList::match_case; // Toggle match case
				this->SetWidgetLoweredState(WID_SIL_FILTER_MATCH_CASE_BTN, SignList::match_case); // Toggle button pushed state
				this->InvalidateData(); // Rebuild the list of signs
				break;
		}
	}

	void OnResize() override
	{
		this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.Vertical());
	}

	void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
	{
		switch (widget) {
			case WID_SIL_LIST: {
				Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
				this->text_offset = WidgetDimensions::scaled.frametext.left + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
				resize->height = std::max<uint>(GetCharacterHeight(FS_NORMAL), spr_dim.height + 2);
				Dimension d = {(uint)(this->text_offset + WidgetDimensions::scaled.frametext.right), padding.height + 5 * resize->height};
				*size = maxdim(*size, d);
				break;
			}

			case WID_SIL_CAPTION:
				SetDParamMaxValue(0, Sign::GetPoolSize(), 3);
				*size = GetStringBoundingBox(STR_SIGN_LIST_CAPTION);
				size->height += padding.height;
				size->width  += padding.width;
				break;
		}
	}

	EventState OnHotkey(int hotkey) override
	{
		switch (hotkey) {
			case SLHK_FOCUS_FILTER_BOX:
				this->SetFocusedWidget(WID_SIL_FILTER_TEXT);
				SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
				break;

			default:
				return ES_NOT_HANDLED;
		}

		return ES_HANDLED;
	}

	void OnEditboxChanged(WidgetID widget) override
	{
		if (widget == WID_SIL_FILTER_TEXT) this->SetFilterString(this->filter_editbox.text.buf);
	}

	void BuildSortSignList()
	{
		if (this->signs.NeedRebuild()) {
			this->BuildSignsList();
			this->vscroll->SetCount(this->signs.size());
			this->SetWidgetDirty(WID_SIL_CAPTION);
		}
		this->SortSignsList();
	}

	/** Resort the sign listing on a regular interval. */
	IntervalTimer<TimerWindow> rebuild_interval = {std::chrono::seconds(3), [this](auto) {
		this->BuildSortSignList();
		this->SetDirty();
	}};

	/**
	 * 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([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
	{
		/* When there is a filter string, we always need to rebuild the list even if
		 * the amount of signs in total is unchanged, as the subset of signs that is
		 * accepted by the filter might has changed. */
		if (data == 0 || data == -1 || !this->string_filter.IsEmpty()) { // New or deleted sign, changed visibility setting or there is a filter string
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
			this->signs.ForceRebuild();
		} else { // Change of sign contents while there is no filter string
			this->signs.ForceResort();
		}
	}

	/**
	 * Handler for global hotkeys of the SignListWindow.
	 * @param hotkey Hotkey
	 * @return ES_HANDLED if hotkey was accepted.
	 */
	static EventState SignListGlobalHotkeys(int hotkey)
	{
		if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
		Window *w = ShowSignList();
		if (w == nullptr) return ES_NOT_HANDLED;
		return w->OnHotkey(hotkey);
	}

	static inline HotkeyList hotkeys{"signlist", {
		Hotkey('F', "focus_filter_box", SLHK_FOCUS_FILTER_BOX),
	}, SignListGlobalHotkeys};
};

static constexpr NWidgetPart _nested_sign_list_widgets[] = {
	NWidget(NWID_HORIZONTAL),
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
		NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SIL_CAPTION), SetDataTip(STR_SIGN_LIST_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(WWT_PANEL, COLOUR_BROWN, WID_SIL_LIST), SetMinimalSize(WidgetDimensions::unscaled.frametext.Horizontal() + 16 + 255, 0),
								SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_SIL_SCROLLBAR), EndContainer(),
			NWidget(NWID_HORIZONTAL),
				NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 1),
					NWidget(WWT_EDITBOX, COLOUR_BROWN, WID_SIL_FILTER_TEXT), SetMinimalSize(80, 12), SetResize(1, 0), SetFill(1, 0), SetPadding(2, 2, 2, 2),
							SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
				EndContainer(),
				NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SIL_FILTER_MATCH_CASE_BTN), SetDataTip(STR_SIGN_LIST_MATCH_CASE, STR_SIGN_LIST_MATCH_CASE_TOOLTIP),
			EndContainer(),
		EndContainer(),
		NWidget(NWID_VERTICAL),
			NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_SIL_SCROLLBAR),
			NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
		EndContainer(),
	EndContainer(),
};

static WindowDesc _sign_list_desc(__FILE__, __LINE__,
	WDP_AUTO, "list_signs", 358, 138,
	WC_SIGN_LIST, WC_NONE,
	0,
	std::begin(_nested_sign_list_widgets), std::end(_nested_sign_list_widgets),
	&SignListWindow::hotkeys
);

/**
 * Open the sign list window
 *
 * @return newly opened sign list window, or nullptr if the window could not be opened.
 */
Window *ShowSignList()
{
	return AllocateWindowDescFront<SignListWindow>(&_sign_list_desc, 0);
}

/**
 * Actually rename the sign.
 * @param index the sign to rename.
 * @param text  the new name.
 * @return true if the window will already be removed after returning.
 */
static bool RenameSign(SignID index, const char *text)
{
	bool remove = StrEmpty(text);
	Command<CMD_RENAME_SIGN>::Post(StrEmpty(text) ? STR_ERROR_CAN_T_DELETE_SIGN : STR_ERROR_CAN_T_CHANGE_SIGN_NAME, index, text);
	return remove;
}

struct SignWindow : Window, SignList {
	QueryString name_editbox;
	SignID cur_sign;

	SignWindow(WindowDesc *desc, const Sign *si) : Window(desc), name_editbox(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS)
	{
		this->querystrings[WID_QES_TEXT] = &this->name_editbox;
		this->name_editbox.caption = STR_EDIT_SIGN_CAPTION;
		this->name_editbox.cancel_button = WID_QES_CANCEL;
		this->name_editbox.ok_button = WID_QES_OK;

		this->InitNested(WN_QUERY_STRING_SIGN);

		UpdateSignEditWindow(si);
		this->SetFocusedWidget(WID_QES_TEXT);
	}

	void UpdateSignEditWindow(const Sign *si)
	{
		/* Display an empty string when the sign hasn't been edited yet */
		if (!si->name.empty()) {
			SetDParam(0, si->index);
			this->name_editbox.text.Assign(STR_SIGN_NAME);
		} else {
			this->name_editbox.text.DeleteAll();
		}

		this->cur_sign = si->index;

		this->SetWidgetDirty(WID_QES_TEXT);
		this->SetFocusedWidget(WID_QES_TEXT);
	}

	/**
	 * Returns a pointer to the (alphabetically) previous or next sign of the current sign.
	 * @param next false if the previous sign is wanted, true if the next sign is wanted
	 * @return pointer to the previous/next sign
	 */
	const Sign *PrevNextSign(bool next)
	{
		/* Rebuild the sign list */
		this->signs.ForceRebuild();
		this->signs.NeedResort();
		this->BuildSignsList();
		this->SortSignsList();

		/* Search through the list for the current sign, excluding
		 * - the first sign if we want the previous sign or
		 * - the last sign if we want the next sign */
		size_t end = this->signs.size() - (next ? 1 : 0);
		for (uint i = next ? 0 : 1; i < end; i++) {
			if (this->cur_sign == this->signs[i]->index) {
				/* We've found the current sign, so return the sign before/after it */
				return this->signs[i + (next ? 1 : -1)];
			}
		}
		/* If we haven't found the current sign by now, return the last/first sign */
		return next ? this->signs.front() : this->signs.back();
	}

	void SetStringParameters(WidgetID widget) const override
	{
		switch (widget) {
			case WID_QES_CAPTION:
				SetDParam(0, this->name_editbox.caption);
				break;
		}
	}

	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
	{
		switch (widget) {
			case WID_QES_LOCATION: {
				const Sign *si = Sign::Get(this->cur_sign);
				TileIndex tile = TileVirtXY(si->x, si->y);
				if (_ctrl_pressed) {
					ShowExtraViewportWindow(tile);
				} else {
					ScrollMainWindowToTile(tile);
				}
				break;
			}

			case WID_QES_PREVIOUS:
			case WID_QES_NEXT: {
				const Sign *si = this->PrevNextSign(widget == WID_QES_NEXT);

				/* Rebuild the sign list */
				this->signs.ForceRebuild();
				this->signs.NeedResort();
				this->BuildSignsList();
				this->SortSignsList();

				/* Scroll to sign and reopen window */
				ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
				UpdateSignEditWindow(si);
				break;
			}

			case WID_QES_DELETE:
				/* Only need to set the buffer to null, the rest is handled as the OK button */
				RenameSign(this->cur_sign, "");
				/* don't delete this, we are deleted in Sign::~Sign() -> DeleteRenameSignWindow() */
				break;

			case WID_QES_OK:
				if (RenameSign(this->cur_sign, this->name_editbox.text.buf)) break;
				FALLTHROUGH;

			case WID_QES_CANCEL:
				this->Close();
				break;
		}
	}
};

static constexpr NWidgetPart _nested_query_sign_edit_widgets[] = {
	NWidget(NWID_HORIZONTAL),
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
		NWidget(WWT_CAPTION, COLOUR_GREY, WID_QES_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
		NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_QES_LOCATION), SetMinimalSize(12, 14), SetDataTip(SPR_GOTO_LOCATION, STR_EDIT_SIGN_LOCATION_TOOLTIP),
	EndContainer(),
	NWidget(WWT_PANEL, COLOUR_GREY),
		NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QES_TEXT), SetMinimalSize(256, 12), SetDataTip(STR_EDIT_SIGN_SIGN_OSKTITLE, STR_NULL), SetPadding(2, 2, 2, 2),
	EndContainer(),
	NWidget(NWID_HORIZONTAL),
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_OK), SetMinimalSize(61, 12), SetDataTip(STR_BUTTON_OK, STR_NULL),
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_CANCEL), SetMinimalSize(60, 12), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_DELETE), SetMinimalSize(60, 12), SetDataTip(STR_TOWN_VIEW_DELETE_BUTTON, STR_NULL),
		NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(),
		NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_QES_PREVIOUS), SetMinimalSize(11, 12), SetDataTip(AWV_DECREASE, STR_EDIT_SIGN_PREVIOUS_SIGN_TOOLTIP),
		NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_QES_NEXT), SetMinimalSize(11, 12), SetDataTip(AWV_INCREASE, STR_EDIT_SIGN_NEXT_SIGN_TOOLTIP),
	EndContainer(),
};

static WindowDesc _query_sign_edit_desc(__FILE__, __LINE__,
	WDP_CENTER, nullptr, 0, 0,
	WC_QUERY_STRING, WC_NONE,
	WDF_CONSTRUCTION,
	std::begin(_nested_query_sign_edit_widgets), std::end(_nested_query_sign_edit_widgets)
);

/**
 * Handle clicking on a sign.
 * @param si The sign that was clicked on.
 */
void HandleClickOnSign(const Sign *si)
{
	/* If we can't rename the sign, don't even open the rename GUI. */
	if (!CompanyCanRenameSign(si)) return;

	if (_ctrl_pressed && (si->owner == _local_company || (si->owner == OWNER_DEITY && _game_mode == GM_EDITOR))) {
		RenameSign(si->index, "");
		return;
	}

	ShowRenameSignWindow(si);
}

/**
 * Show the window to change the text of a sign.
 * @param si The sign to show the window for.
 */
void ShowRenameSignWindow(const Sign *si)
{
	/* Delete all other edit windows */
	CloseWindowByClass(WC_QUERY_STRING);

	new SignWindow(&_query_sign_edit_desc, si);
}

/**
 * Close the sign window associated with the given sign.
 * @param sign The sign to close the window for.
 */
void DeleteRenameSignWindow(SignID sign)
{
	SignWindow *w = dynamic_cast<SignWindow *>(FindWindowById(WC_QUERY_STRING, WN_QUERY_STRING_SIGN));

	if (w != nullptr && w->cur_sign == sign) w->Close();
}