station_gui.c
author peter1138
Fri, 20 Oct 2006 11:53:29 +0000
changeset 4896 72d7a8614580
parent 4727 ba5bae41b004
child 4912 d04b3f2bca70
permissions -rw-r--r--
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1820
diff changeset
     4
#include "openttd.h"
1299
0a6510cc889b (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1272
diff changeset
     5
#include "debug.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     6
#include "functions.h"
1309
dab90d4cbf2d (svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents: 1299
diff changeset
     7
#include "strings.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 487
diff changeset
     8
#include "table/strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "station.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "player.h"
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    14
#include "economy.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "town.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "command.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2084
diff changeset
    17
#include "variables.h"
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2084
diff changeset
    18
#include "vehicle_gui.h"
4261
2ec8f5a9747b (svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents: 3859
diff changeset
    19
#include "date.h"
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
    20
#include "vehicle.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    22
typedef int CDECL StationSortListingTypeFunction(const void*, const void*);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    23
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    24
static StationSortListingTypeFunction StationNameSorter;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    25
static StationSortListingTypeFunction StationTypeSorter;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    26
static StationSortListingTypeFunction StationWaitingSorter;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    27
static StationSortListingTypeFunction StationRatingMaxSorter;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    28
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
static void StationsWndShowStationRating(int x, int y, int type, uint acceptance, int rating)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
{
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    31
	static const byte _rating_colors[NUM_CARGO] = {152, 32, 15, 174, 208, 194, 191, 55, 184, 10, 191, 48};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
	int color = _rating_colors[type];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
	uint w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    35
	if (acceptance > 575) acceptance = 575;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    36
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    37
	acceptance = (acceptance + 7) / 8;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
	/* draw cargo */
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    40
	w = acceptance / 8;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    41
	if (w != 0) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    42
		GfxFillRect(x, y, x + w - 1, y + 6, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
		x += w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    46
	w = acceptance % 8;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    47
	if (w != 0) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    48
		if (w == 7) w--;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    49
		GfxFillRect(x, y + (w - 1), x, y + 6, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    52
	x -= acceptance / 8;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    53
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    54
	DrawString(x + 1, y, _cargoc.names_short[type], 0x10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	/* draw green/red ratings bar */
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    57
	GfxFillRect(x + 1, y + 8, x + 7, y + 8, 0xB8);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    58
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    59
	rating >>= 5;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
    61
	if (rating != 0) GfxFillRect(x + 1, y + 8, x + rating, y + 8, 0xD0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    64
const StringID _station_sort_listing[] = {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    65
	STR_SORT_BY_DROPDOWN_NAME,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    66
	STR_SORT_BY_FACILITY,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    67
	STR_SORT_BY_WAITING,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    68
	STR_SORT_BY_RATING_MAX,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    69
	INVALID_STRING_ID
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    70
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
static char _bufcache[64];
4277
3539bd14f023 (svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents: 4268
diff changeset
    73
static const Station* _last_station;
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    74
static int _internal_sort_order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 69
diff changeset
    76
static int CDECL StationNameSorter(const void *a, const void *b)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
{
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
    78
	const Station* st1 = *(const Station**)a;
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
    79
	const Station* st2 = *(const Station**)b;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	char buf1[64];
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    81
	int r;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
4416
e0e9a72882d0 (svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents: 4354
diff changeset
    83
	SetDParam(0, st1->index);
e0e9a72882d0 (svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents: 4354
diff changeset
    84
	GetString(buf1, STR_STATION);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 69
diff changeset
    85
4277
3539bd14f023 (svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents: 4268
diff changeset
    86
	if (st2 != _last_station) {
3539bd14f023 (svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents: 4268
diff changeset
    87
		_last_station = st2;
4416
e0e9a72882d0 (svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents: 4354
diff changeset
    88
		SetDParam(0, st2->index);
e0e9a72882d0 (svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents: 4354
diff changeset
    89
		GetString(_bufcache, STR_STATION);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 69
diff changeset
    90
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    92
	r =  strcmp(buf1, _bufcache); // sort by name
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    93
	return (_internal_sort_order & 1) ? -r : r;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    96
static int CDECL StationTypeSorter(const void *a, const void *b)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
{
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
    98
	const Station* st1 = *(const Station**)a;
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
    99
	const Station* st2 = *(const Station**)b;
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   100
	return (_internal_sort_order & 1) ? st2->facilities - st1->facilities : st1->facilities - st2->facilities;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   101
}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   102
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   103
static int CDECL StationWaitingSorter(const void *a, const void *b)
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   104
{
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   105
	const Station* st1 = *(const Station**)a;
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   106
	const Station* st2 = *(const Station**)b;
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   107
	int sum1 = 0, sum2 = 0;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   108
	int j;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   109
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   110
	for (j = 0; j < NUM_CARGO; j++) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   111
		if (st1->goods[j].waiting_acceptance & 0xfff) sum1 += GetTransportedGoodsIncome(st1->goods[j].waiting_acceptance & 0xfff, 20, 50, j);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   112
		if (st2->goods[j].waiting_acceptance & 0xfff) sum2 += GetTransportedGoodsIncome(st2->goods[j].waiting_acceptance & 0xfff, 20, 50, j);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   113
	}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   114
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   115
	return (_internal_sort_order & 1) ? sum2 - sum1 : sum1 - sum2;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   116
}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   117
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   118
static int CDECL StationRatingMaxSorter(const void *a, const void *b)
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   119
{
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   120
	const Station* st1 = *(const Station**)a;
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   121
	const Station* st2 = *(const Station**)b;
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   122
	byte maxr1 = 0;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   123
	byte maxr2 = 0;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   124
	int j;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   125
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   126
	for (j = 0; j < NUM_CARGO; j++) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   127
		if (st1->goods[j].waiting_acceptance & 0xfff) maxr1 = max(maxr1, st1->goods[j].rating);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   128
		if (st2->goods[j].waiting_acceptance & 0xfff) maxr2 = max(maxr2, st2->goods[j].rating);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   129
	}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   130
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   131
	return (_internal_sort_order & 1) ? maxr2 - maxr1 : maxr1 - maxr2;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   132
}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   133
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   134
typedef enum StationListFlags {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   135
	SL_ORDER   = 0x01,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   136
	SL_RESORT  = 0x02,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   137
	SL_REBUILD = 0x04,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   138
} StationListFlags;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   139
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   140
typedef struct plstations_d {
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   141
	const Station** sort_list;
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   142
	uint16 list_length;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   143
	byte sort_type;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   144
	StationListFlags flags;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   145
	uint16 resort_timer;  //was byte refresh_counter;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   146
} plstations_d;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   147
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(plstations_d));
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   148
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   149
void RebuildStationLists(void)
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   150
{
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   151
	Window *w;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   152
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   153
	for (w = _windows; w != _last_window; ++w) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   154
		if (w->window_class == WC_STATION_LIST) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   155
			WP(w, plstations_d).flags |= SL_REBUILD;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   156
			SetWindowDirty(w);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   157
		}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   158
	}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   159
}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   160
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   161
void ResortStationLists(void)
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   162
{
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   163
	Window *w;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   164
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   165
	for (w = _windows; w != _last_window; ++w) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   166
		if (w->window_class == WC_STATION_LIST) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   167
			WP(w, plstations_d).flags |= SL_RESORT;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   168
			SetWindowDirty(w);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   169
		}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   170
	}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   171
}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   172
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   173
static void BuildStationsList(plstations_d* sl, PlayerID owner, byte facilities, uint16 cargo_filter)
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   174
{
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   175
	uint n = 0;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   176
	uint i, j;
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   177
	const Station** station_sort;
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 222
diff changeset
   178
	const Station *st;
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 222
diff changeset
   179
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   180
	if (!(sl->flags & SL_REBUILD)) return;
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   181
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   182
	/* Create array for sorting */
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4346
diff changeset
   183
	station_sort = malloc(GetStationArraySize() * sizeof(station_sort[0]));
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   184
	if (station_sort == NULL)
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   185
		error("Could not allocate memory for the station-sorting-list");
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   187
	DEBUG(misc, 1) ("Building station list for player %d...", owner);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   188
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
	FOR_ALL_STATIONS(st) {
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   190
		if (st->owner == owner) {
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   191
			if (facilities & st->facilities) { //only stations with selected facilities
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   192
				int num_waiting_cargo = 0;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   193
				for (j = 0; j < NUM_CARGO; j++) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   194
					if (st->goods[j].waiting_acceptance & 0xFFF) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   195
						num_waiting_cargo++; //count number of waiting cargo
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   196
						if (HASBIT(cargo_filter, j)) {
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   197
							station_sort[n++] = st;
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   198
							break;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   199
						}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   200
					}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   201
				}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   202
				//stations without waiting cargo
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   203
				if (num_waiting_cargo == 0 && HASBIT(cargo_filter, NUM_CARGO)) {
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   204
					station_sort[n++] = st;
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   205
				}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   206
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
4277
3539bd14f023 (svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents: 4268
diff changeset
   210
	free((void*)sl->sort_list);
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   211
	sl->sort_list = malloc(n * sizeof(sl->sort_list[0]));
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   212
	if (n != 0 && sl->sort_list == NULL) error("Could not allocate memory for the station-sorting-list");
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   213
	sl->list_length = n;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   215
	for (i = 0; i < n; ++i) sl->sort_list[i] = station_sort[i];
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 69
diff changeset
   216
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   217
	sl->flags &= ~SL_REBUILD;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   218
	sl->flags |= SL_RESORT;
4277
3539bd14f023 (svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents: 4268
diff changeset
   219
	free((void*)station_sort);
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 222
diff changeset
   220
}
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 222
diff changeset
   221
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   222
static void SortStationsList(plstations_d *sl)
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 222
diff changeset
   223
{
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   224
	static StationSortListingTypeFunction* const _station_sorter[] = {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   225
		&StationNameSorter,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   226
		&StationTypeSorter,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   227
		&StationWaitingSorter,
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   228
		&StationRatingMaxSorter
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   229
	};
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 69
diff changeset
   230
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   231
	if (!(sl->flags & SL_RESORT)) return;
174
bd79fb899824 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents: 164
diff changeset
   232
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   233
	_internal_sort_order = sl->flags & SL_ORDER;
4277
3539bd14f023 (svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents: 4268
diff changeset
   234
	_last_station = NULL; // used for "cache" in namesorting
4280
3265e76b7016 (svn r5910) Fix some more warnings on MSVC by using (void*) casts. Followup of r5907.
Darkvater
parents: 4277
diff changeset
   235
	qsort((void*)sl->sort_list, sl->list_length, sizeof(sl->sort_list[0]), _station_sorter[sl->sort_type]);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   236
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   237
	sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   238
	sl->flags &= ~SL_RESORT;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
static void PlayerStationsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
{
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   243
	const PlayerID owner = w->window_number;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   244
	static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   245
	static uint16 cargo_filter = 0x1FFF;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   246
	plstations_d *sl = &WP(w, plstations_d);
3820
cdd48144c074 (svn r4830) - Codechange: simplify station sorting a bit by recalculating the clicked-states on drawing the window. This also allows the 'Sort by' button to be visually clickable
Darkvater
parents: 3813
diff changeset
   247
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   248
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
	case WE_PAINT: {
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   250
		BuildStationsList(sl, owner, facilities, cargo_filter);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   251
		SortStationsList(sl);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   253
		SetVScrollCount(w, sl->list_length);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
		/* draw widgets, with player's name in the caption */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
		{
2498
befad2fe53d2 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2484
diff changeset
   257
			const Player* p = GetPlayer(owner);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   258
			SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   259
			SetDParam(1, p->name_2);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   260
			SetDParam(2, w->vscroll.count);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
			DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
		{
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   265
			int max;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   266
			int i;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   267
			int x = 0, y = 0, xb = 2; // offset from top of widget
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   268
			static const byte _cargo_legend_colors[NUM_CARGO] = {152, 32, 15, 174, 208, 194, 191, 84, 184, 10, 202, 215};
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   269
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   270
			/* draw sorting criteria string */
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   271
			DrawString(85, 26, _station_sort_listing[sl->sort_type], 0x10);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   272
			/* draw arrow pointing up/down for ascending/descending sorting */
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   273
			DoDrawString(sl->flags & SL_ORDER ? DOWNARROW : UPARROW, 69, 26, 0x10);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   274
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   275
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   276
			x = 90;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   277
			y = 14;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   278
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   279
			for (i = 0; i < NUM_CARGO; i++) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   280
				GfxFillRect(x + 1, y + 2, x + 11, y + 8, _cargo_legend_colors[i]);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   281
				DrawString(x + 3, y + 2, _cargoc.names_short[i], i == 11 ? 15 : 16);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   282
				x += 14;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   283
			}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   284
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   285
			DrawString(x + 2, y + 2, STR_ABBREV_NONE, 16);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   286
			x += 14;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   287
			DrawString(x + 2, y + 2, STR_ABBREV_ALL, 16);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   288
			DrawString(72, y + 2, STR_ABBREV_ALL, 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
2026
02dfa0aa2c2f (svn r2535) Tabs
tron
parents: 1962
diff changeset
   290
			if (w->vscroll.count == 0) { // player has no stations
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   291
				DrawString(xb, 40, STR_304A_NONE, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   294
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   295
			max = min(w->vscroll.pos + w->vscroll.cap, sl->list_length);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   296
			y = 40; // start of the list-widget
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   298
			for (i = w->vscroll.pos; i < max; ++i) { // do until max number of stations of owner
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   299
				const Station* st = sl->sort_list[i];
2630
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   300
				uint j;
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   301
				int x;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   303
				assert(st->xy);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   304
				assert(st->owner == owner);
174
bd79fb899824 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents: 164
diff changeset
   305
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   306
				SetDParam(0, st->index);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   307
				SetDParam(1, st->facilities);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
				x = DrawString(xb, y, STR_3049_0, 0) + 5;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
				// show cargo waiting and station ratings
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   311
				for (j = 0; j != NUM_CARGO; j++) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   312
					uint acc = GB(st->goods[j].waiting_acceptance, 0, 12);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   313
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
					if (acc != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
						StationsWndShowStationRating(x, y, j, acc, st->goods[j].rating);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
						x += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
				y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
	case WE_CLICK: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   324
		switch (e->we.click.widget) {
758
bd9e868b9fae (svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents: 603
diff changeset
   325
		case 3: {
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   326
			const Station* st;
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   327
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   328
			uint32 id_v = (e->we.click.pt.y - 41) / 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   330
			if (id_v >= w->vscroll.cap) return; // click out of bounds
174
bd79fb899824 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents: 164
diff changeset
   331
bd79fb899824 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents: 164
diff changeset
   332
			id_v += w->vscroll.pos;
bd79fb899824 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents: 164
diff changeset
   333
3820
cdd48144c074 (svn r4830) - Codechange: simplify station sorting a bit by recalculating the clicked-states on drawing the window. This also allows the 'Sort by' button to be visually clickable
Darkvater
parents: 3813
diff changeset
   334
			if (id_v >= sl->list_length) return; // click out of list bound
2630
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   335
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   336
			st = sl->sort_list[id_v];
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   337
			assert(st->owner == owner);
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   338
			ScrollMainWindowToTile(st->xy);
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   339
			break;
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   340
		}
174
bd79fb899824 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents: 164
diff changeset
   341
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   342
		case 6: /* train */
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   343
		case 7: /* truck */
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   344
		case 8: /* bus */
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   345
		case 9: /* airport */
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   346
		case 10: /* dock */
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   347
			if (_ctrl_pressed) {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   348
				TOGGLEBIT(facilities, e->we.click.widget - 6);
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   349
				ToggleWidgetLoweredState(w, e->we.click.widget);
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   350
			} else {
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   351
				int i;
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   352
				for (i = 0; facilities != 0; i++, facilities >>= 1) {
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   353
					if (HASBIT(facilities, 0)) RaiseWindowWidget(w, i + 6);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   354
				}
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   355
				SETBIT(facilities, e->we.click.widget - 6);
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   356
				LowerWindowWidget(w, e->we.click.widget);
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   357
			}
4727
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   358
			SetWindowWidgetLoweredState(w, 26, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   359
			sl->flags |= SL_REBUILD;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   360
			SetWindowDirty(w);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   361
		break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   362
		case 26: {
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   363
			int i;
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   364
			for (i = 0; i < 5; i++) {
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   365
				LowerWindowWidget(w, i + 6);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   366
			}
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   367
			LowerWindowWidget(w, 26);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   368
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   369
			facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   370
			sl->flags |= SL_REBUILD;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   371
			SetWindowDirty(w);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   372
			break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   373
		}
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   374
		case 27: {
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   375
			int i;
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   376
			for (i = 0; i < NUM_CARGO; i++) {
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   377
				LowerWindowWidget(w, i + 12);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   378
			}
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   379
			LowerWindowWidget(w, 27);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   380
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   381
			cargo_filter = 0x1FFF; /* select everything */
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   382
			sl->flags |= SL_REBUILD;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   383
			SetWindowDirty(w);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   384
			break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   385
		}
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   386
		case 28: /*flip sorting method asc/desc*/
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   387
			TOGGLEBIT(sl->flags, 0); //DESC-flag
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   388
			sl->flags |= SL_RESORT;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   389
			SetWindowDirty(w);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   390
		break;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   391
		case 29: case 30: /* select sorting criteria dropdown menu */
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   392
			ShowDropDownMenu(w, _station_sort_listing, sl->sort_type, 30, 0, 0);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   393
		break;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   394
		default:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   395
			if (e->we.click.widget >= 12 && e->we.click.widget <= 24) { //change cargo_filter
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   396
				if (_ctrl_pressed) {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   397
					TOGGLEBIT(cargo_filter, e->we.click.widget - 12);
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   398
					ToggleWidgetLoweredState(w, e->we.click.widget);
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   399
				} else {
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   400
					int i;
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   401
					for (i = 0; cargo_filter != 0; i++, cargo_filter >>= 1) {
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   402
						if (HASBIT(cargo_filter, 0)) RaiseWindowWidget(w, i + 12);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   403
					}
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   404
					SETBIT(cargo_filter, e->we.click.widget - 12);
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   405
					LowerWindowWidget(w, e->we.click.widget);
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   406
				}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   407
				sl->flags |= SL_REBUILD;
4727
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   408
				SetWindowWidgetLoweredState(w, 27, cargo_filter == 0x1FFF);
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   409
				SetWindowDirty(w);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   410
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
	} break;
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   413
	case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   414
		if (sl->sort_type != e->we.dropdown.index) {
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   415
			// value has changed -> resort
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   416
			sl->sort_type = e->we.dropdown.index;
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   417
			sl->flags |= SL_RESORT;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   418
		}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   419
		SetWindowDirty(w);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   420
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   422
	case WE_TICK:
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   423
		if (--sl->resort_timer == 0) {
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   424
			DEBUG(misc, 1) ("Periodic rebuild station list player %d", owner);
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   425
			sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   426
			sl->flags |= VL_REBUILD;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
		break;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   430
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   431
	case WE_CREATE: { /* set up resort timer */
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   432
		int i;
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   433
		for (i = 0; i < 5; i++) {
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   434
			if (HASBIT(facilities, i)) LowerWindowWidget(w, i + 6);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   435
		}
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   436
		for (i = 0; i < NUM_CARGO; i++) {
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   437
			if (HASBIT(cargo_filter, i)) LowerWindowWidget(w, i + 12);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   438
		}
4727
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   439
		SetWindowWidgetLoweredState(w, 26, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   440
		SetWindowWidgetLoweredState(w, 27, cargo_filter == 0x1FFF);
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   441
		sl->sort_list = NULL;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   442
		sl->flags = SL_REBUILD;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   443
		sl->sort_type = 0;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   444
		sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   445
		break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   446
	}
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   447
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   448
	case WE_RESIZE:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   449
		w->vscroll.cap += e->we.sizing.diff.y / 10;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   450
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
static const Widget _player_stations_widgets[] = {
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   455
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   456
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   345,     0,    13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   457
{  WWT_STICKYBOX,     RESIZE_LR,    14,   346,   357,     0,    13, 0x0,               STR_STICKY_BUTTON},
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   458
{      WWT_PANEL,     RESIZE_RB,    14,     0,   345,    37,   161, 0x0,               STR_3057_STATION_NAMES_CLICK_ON},
3859
2b8cc232048d (svn r4891) - Fix (r4822): The station list window had some overlapping widgets (peter1138)
Darkvater
parents: 3820
diff changeset
   459
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   346,   357,    25,   149, 0x0,               STR_0190_SCROLL_BAR_SCROLLS_LIST},
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   460
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   346,   357,   150,   161, 0x0,               STR_RESIZE_BUTTON},
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   461
//Index 6
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   462
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    13,    14,    24, STR_TRAIN,         STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   463
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    14,    27,    14,    24, STR_LORRY,         STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   464
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    28,    41,    14,    24, STR_BUS,           STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   465
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    42,    55,    14,    24, STR_PLANE,         STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   466
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    56,    69,    14,    24, STR_SHIP,          STR_USE_CTRL_TO_SELECT_MORE},
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   467
//Index 11
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   468
{      WWT_PANEL,   RESIZE_NONE,    14,    83,    88,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   469
{      WWT_PANEL,   RESIZE_NONE,    14,    89,   102,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   470
{      WWT_PANEL,   RESIZE_NONE,    14,   103,   116,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   471
{      WWT_PANEL,   RESIZE_NONE,    14,   117,   130,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   472
{      WWT_PANEL,   RESIZE_NONE,    14,   131,   144,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   473
{      WWT_PANEL,   RESIZE_NONE,    14,   145,   158,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   474
{      WWT_PANEL,   RESIZE_NONE,    14,   159,   172,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   475
{      WWT_PANEL,   RESIZE_NONE,    14,   173,   186,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   476
{      WWT_PANEL,   RESIZE_NONE,    14,   187,   200,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   477
{      WWT_PANEL,   RESIZE_NONE,    14,   201,   214,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   478
{      WWT_PANEL,   RESIZE_NONE,    14,   215,   228,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   479
{      WWT_PANEL,   RESIZE_NONE,    14,   229,   242,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   480
{      WWT_PANEL,   RESIZE_NONE,    14,   243,   256,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   481
{      WWT_PANEL,   RESIZE_NONE,    14,   257,   270,    14,    24, 0x0,               STR_NO_WAITING_CARGO},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   482
{      WWT_PANEL,  RESIZE_RIGHT,    14,   285,   357,    14,    24, 0x0,               STR_NULL},
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   483
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   484
//26
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   485
{      WWT_PANEL,   RESIZE_NONE,    14,    70,    83,    14,    24, 0x0,               STR_SELECT_ALL_FACILITIES},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   486
{      WWT_PANEL,   RESIZE_NONE,    14,   271,   284,    14,    24, 0x0,               STR_SELECT_ALL_TYPES},
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   487
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   488
//28
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   489
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    25,    36, STR_SORT_BY,       STR_SORT_ORDER_TIP},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   490
{      WWT_PANEL,   RESIZE_NONE,    14,    81,   232,    25,    36, 0x0,               STR_SORT_CRITERIA_TIP},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   491
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   233,   243,    25,    36, STR_0225,          STR_SORT_CRITERIA_TIP},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4299
diff changeset
   492
{      WWT_PANEL,  RESIZE_RIGHT,    14,   244,   345,    25,    36, 0x0,               STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 174
diff changeset
   493
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
static const WindowDesc _player_stations_desc = {
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   497
	-1, -1, 358, 162,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
	WC_STATION_LIST,0,
3820
cdd48144c074 (svn r4830) - Codechange: simplify station sorting a bit by recalculating the clicked-states on drawing the window. This also allows the 'Sort by' button to be visually clickable
Darkvater
parents: 3813
diff changeset
   499
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
	_player_stations_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
	PlayerStationsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2186
diff changeset
   505
void ShowPlayerStations(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
	w = AllocateWindowDescFront(&_player_stations_desc, player);
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2544
diff changeset
   510
	if (w != NULL) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
		w->caption_color = (byte)w->window_number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
		w->vscroll.cap = 12;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   513
		w->resize.step_height = 10;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   514
		w->resize.height = w->height - 10 * 7; // minimum if 5 in the list
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
static const Widget _station_view_expanded_widgets[] = {
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   519
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   520
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   236,     0,    13, STR_300A_0,        STR_018C_WINDOW_TITLE_DRAG_THIS},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   521
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   237,   248,     0,    13, 0x0,               STR_STICKY_BUTTON},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   522
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   236,    14,    65, 0x0,               STR_NULL},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   523
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   237,   248,    14,    65, 0x0,               STR_0190_SCROLL_BAR_SCROLLS_LIST},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   524
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,               STR_NULL},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   525
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   248,    66,   197, 0x0,               STR_NULL},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   526
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    63,   198,   209, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   527
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    64,   128,   198,   209, STR_3033_ACCEPTS,  STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   528
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   129,   192,   198,   209, STR_0130_RENAME,   STR_3055_CHANGE_NAME_OF_STATION},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   529
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   193,   206,   198,   209, STR_TRAIN,         STR_SCHEDULED_TRAINS_TIP },
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   530
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   207,   220,   198,   209, STR_LORRY,         STR_SCHEDULED_ROAD_VEHICLES_TIP },
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   531
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   221,   234,   198,   209, STR_PLANE,         STR_SCHEDULED_AIRCRAFT_TIP },
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   532
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   235,   248,   198,   209, STR_SHIP,          STR_SCHEDULED_SHIPS_TIP },
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 174
diff changeset
   533
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
static const Widget _station_view_widgets[] = {
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   537
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   538
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   236,     0,    13, STR_300A_0,        STR_018C_WINDOW_TITLE_DRAG_THIS},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   539
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   237,   248,     0,    13, 0x0,               STR_STICKY_BUTTON},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   540
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   236,    14,    65, 0x0,               STR_NULL},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   541
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   237,   248,    14,    65, 0x0,               STR_0190_SCROLL_BAR_SCROLLS_LIST},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   542
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   248,    66,    97, 0x0,               STR_NULL},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   543
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,               STR_NULL},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   544
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    63,    98,   109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   545
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    64,   128,    98,   109, STR_3032_RATINGS,  STR_3054_SHOW_STATION_RATINGS},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   546
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   129,   192,    98,   109, STR_0130_RENAME,   STR_3055_CHANGE_NAME_OF_STATION},
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   547
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   193,   206,    98,   109, STR_TRAIN,         STR_SCHEDULED_TRAINS_TIP },
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   548
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   207,   220,    98,   109, STR_LORRY,         STR_SCHEDULED_ROAD_VEHICLES_TIP },
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   549
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   221,   234,    98,   109, STR_PLANE,         STR_SCHEDULED_AIRCRAFT_TIP },
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   550
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   235,   248,    98,   109, STR_SHIP,          STR_SCHEDULED_SHIPS_TIP },
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 174
diff changeset
   551
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
static void DrawStationViewWindow(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
{
2630
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   556
	StationID station_id = w->window_number;
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   557
	const Station* st = GetStation(station_id);
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   558
	uint i;
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   559
	uint num;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
	int x,y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
	int pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
	StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
	num = 1;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   565
	for (i = 0; i != NUM_CARGO; i++) {
2504
7c27fc230cda (svn r3030) More work for GB/SB, this time concerning the waiting_acceptance attribute of stations
tron
parents: 2498
diff changeset
   566
		if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
			num++;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   568
			if (st->goods[i].enroute_from != station_id) num++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
	SetVScrollCount(w, num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
   573
	SetWindowWidgetDisabledState(w,  9, st->owner != _local_player);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
   574
	SetWindowWidgetDisabledState(w, 10, !(st->facilities & FACIL_TRAIN));
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
   575
	SetWindowWidgetDisabledState(w, 11, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
   576
	SetWindowWidgetDisabledState(w, 12, !(st->facilities & FACIL_AIRPORT));
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
   577
	SetWindowWidgetDisabledState(w, 13, !(st->facilities & FACIL_DOCK));
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   578
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   579
	SetDParam(0, st->index);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   580
	SetDParam(1, st->facilities);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
	DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
	x = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
	y = 15;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
	pos = w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
	if (--pos < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
		str = STR_00D0_NOTHING;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   589
		for (i = 0; i != NUM_CARGO; i++) {
2504
7c27fc230cda (svn r3030) More work for GB/SB, this time concerning the waiting_acceptance attribute of stations
tron
parents: 2498
diff changeset
   590
			if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) str = STR_EMPTY;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   591
		}
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   592
		SetDParam(0, str);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
		DrawString(x, y, STR_0008_WAITING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
		y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
	i = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
	do {
2504
7c27fc230cda (svn r3030) More work for GB/SB, this time concerning the waiting_acceptance attribute of stations
tron
parents: 2498
diff changeset
   599
		uint waiting = GB(st->goods[i].waiting_acceptance, 0, 12);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   600
		if (waiting == 0) continue;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   601
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
		num = (waiting + 5) / 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
		if (num != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
			int cur_x = x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
			num = min(num, 23);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
				DrawSprite(_cargoc.sprites[i], cur_x, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
				cur_x += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
			} while (--num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
		if ( st->goods[i].enroute_from == station_id) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   613
			if (--pos < 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   614
				SetDParam(1, waiting);
4896
72d7a8614580 (svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents: 4727
diff changeset
   615
				SetDParam(0, i);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   616
				DrawStringRightAligned(x + 234, y, STR_0009, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   617
				y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   619
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
			/* enroute */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
			if (--pos < 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   622
				SetDParam(1, waiting);
4896
72d7a8614580 (svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents: 4727
diff changeset
   623
				SetDParam(0, i);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
				DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
				y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
			if (pos > -5 && --pos < 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   629
				SetDParam(0, st->goods[i].enroute_from);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
				DrawStringRightAligned(x + 234, y, STR_000B, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
				y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
		}
2638
0c9b00251fce (svn r3180) Replace some magic numbers by symbolic names
tron
parents: 2630
diff changeset
   634
	} while (pos > -5 && ++i != NUM_CARGO);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   635
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   636
	if (IsWindowOfPrototype(w, _station_view_widgets)) {
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   637
		char *b = _userstring;
1329
a8a0d60b0a8e (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
   638
1553
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1474
diff changeset
   639
		b = InlineString(b, STR_000C_ACCEPTS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   641
		for (i = 0; i != NUM_CARGO; i++) {
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   642
			if (b >= endof(_userstring) - 5 - 1) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
			if (st->goods[i].waiting_acceptance & 0x8000) {
1553
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1474
diff changeset
   644
				b = InlineString(b, _cargoc.names_s[i]);
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   645
				*b++ = ',';
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   646
				*b++ = ' ';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   649
1329
a8a0d60b0a8e (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
   650
		if (b == &_userstring[3]) {
1553
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1474
diff changeset
   651
			b = InlineString(b, STR_00D0_NOTHING);
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1474
diff changeset
   652
			*b++ = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   653
		} else {
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   654
			b[-2] = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   655
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   656
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
		DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
		DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   660
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
		y = 77;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   662
		for (i = 0; i != NUM_CARGO; i++) {
1266
9dc5638fe8cc (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1093
diff changeset
   663
			if (st->goods[i].enroute_from != INVALID_STATION) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   664
				SetDParam(0, _cargoc.names_s[i]);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   665
				SetDParam(2, st->goods[i].rating * 101 >> 8);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   666
				SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
				DrawString(8, y, STR_303D, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
				y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   671
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
static void StationViewWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   677
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
		DrawStationViewWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   680
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   681
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   683
		switch (e->we.click.widget) {
758
bd9e868b9fae (svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents: 603
diff changeset
   684
		case 7:
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   685
			ScrollMainWindowToTile(GetStation(w->window_number)->xy);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
758
bd9e868b9fae (svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents: 603
diff changeset
   688
		case 8:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   689
			SetWindowDirty(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   690
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
			/* toggle height/widget set */
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   692
			if (IsWindowOfPrototype(w, _station_view_expanded_widgets)) {
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   693
				AssignWidgetToWindow(w, _station_view_widgets);
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   694
				w->height = 110;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   695
			} else {
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   696
				AssignWidgetToWindow(w, _station_view_expanded_widgets);
893
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 867
diff changeset
   697
				w->height = 210;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   698
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
758
bd9e868b9fae (svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents: 603
diff changeset
   703
		case 9: {
2070
26c657906f25 (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents: 2026
diff changeset
   704
			SetDParam(0, w->window_number);
4299
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4280
diff changeset
   705
			ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, w->window_class, w->window_number, CS_ALPHANUMERAL);
2026
02dfa0aa2c2f (svn r2535) Tabs
tron
parents: 1962
diff changeset
   706
		} break;
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   707
1809
f644ae658ec9 (svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents: 1556
diff changeset
   708
		case 10: { /* Show a list of scheduled trains to this station */
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   709
			const Station *st = GetStation(w->window_number);
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
   710
			ShowVehicleListWindow(st->owner, w->window_number, VEH_Train);
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   711
			break;
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   712
		}
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   713
1809
f644ae658ec9 (svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents: 1556
diff changeset
   714
		case 11: { /* Show a list of scheduled road-vehicles to this station */
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   715
			const Station *st = GetStation(w->window_number);
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
   716
			ShowVehicleListWindow(st->owner, w->window_number, VEH_Road);
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   717
			break;
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   718
		}
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   719
1809
f644ae658ec9 (svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents: 1556
diff changeset
   720
		case 12: { /* Show a list of scheduled aircraft to this station */
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   721
			const Station *st = GetStation(w->window_number);
1809
f644ae658ec9 (svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents: 1556
diff changeset
   722
			/* Since oilrigs have no owners, show the scheduled aircraft of current player */
f644ae658ec9 (svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents: 1556
diff changeset
   723
			PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
   724
			ShowVehicleListWindow(owner, w->window_number, VEH_Aircraft);
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   725
			break;
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   726
		}
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   727
1809
f644ae658ec9 (svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents: 1556
diff changeset
   728
		case 13: { /* Show a list of scheduled ships to this station */
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   729
			const Station *st = GetStation(w->window_number);
1809
f644ae658ec9 (svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents: 1556
diff changeset
   730
			/* Since oilrigs/bouys have no owners, show the scheduled ships of current player */
f644ae658ec9 (svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents: 1556
diff changeset
   731
			PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
   732
			ShowVehicleListWindow(owner, w->window_number, VEH_Ship);
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   733
			break;
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   734
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   735
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2544
diff changeset
   738
	case WE_ON_EDIT_TEXT:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   739
		if (e->we.edittext.str[0] != '\0') {
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   740
			_cmd_text = e->we.edittext.str;
2543
a6344040f735 (svn r3072) CMD_RENAME_STATION isn't interested in the tile coordinates, so don't pass them
tron
parents: 2504
diff changeset
   741
			DoCommandP(0, w->window_number, 0, NULL,
1820
9b6458526480 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1809
diff changeset
   742
				CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION));
9b6458526480 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1809
diff changeset
   743
		}
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2544
diff changeset
   744
		break;
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   745
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   746
	case WE_DESTROY: {
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   747
		WindowNumber wno =
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   748
			(w->window_number << 16) | GetStation(w->window_number)->owner;
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   749
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   750
		DeleteWindowById(WC_TRAINS_LIST, wno);
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   751
		DeleteWindowById(WC_ROADVEH_LIST, wno);
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   752
		DeleteWindowById(WC_SHIPS_LIST, wno);
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   753
		DeleteWindowById(WC_AIRCRAFT_LIST, wno);
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   754
		break;
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   755
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   756
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   757
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   758
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   759
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   760
static const WindowDesc _station_view_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   761
	-1, -1, 249, 110,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
	WC_STATION_VIEW,0,
758
bd9e868b9fae (svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents: 603
diff changeset
   763
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   764
	_station_view_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   765
	StationViewWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   766
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   767
2498
befad2fe53d2 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2484
diff changeset
   768
void ShowStationViewWindow(StationID station)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   771
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
	w = AllocateWindowDescFront(&_station_view_desc, station);
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2544
diff changeset
   773
	if (w != NULL) {
2544
50cb52cdeb73 (svn r3073) int/byte -> EngineID/PlayerID/VehicleID
tron
parents: 2543
diff changeset
   774
		PlayerID owner = GetStation(w->window_number)->owner;
50cb52cdeb73 (svn r3073) int/byte -> EngineID/PlayerID/VehicleID
tron
parents: 2543
diff changeset
   775
		if (owner != OWNER_NONE) w->caption_color = owner;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   776
		w->vscroll.cap = 5;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   777
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   778
}