src/station_gui.cpp
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6307 f40e88cff863
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
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
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
     3
/** @file station_gui.cpp */
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1820
diff changeset
     6
#include "openttd.h"
1299
0a6510cc889b (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1272
diff changeset
     7
#include "debug.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     8
#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
     9
#include "strings.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 487
diff changeset
    10
#include "table/strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "station.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#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
    16
#include "economy.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "town.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
#include "command.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2084
diff changeset
    19
#include "variables.h"
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2084
diff changeset
    20
#include "vehicle_gui.h"
4261
2ec8f5a9747b (svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents: 3859
diff changeset
    21
#include "date.h"
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
    22
#include "vehicle.h"
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5860
diff changeset
    23
#include "table/sprites.h"
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
    24
#include "helpers.hpp"
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6263
diff changeset
    25
#include "cargotype.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
5271
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    27
enum StationListWidgets {
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    28
	STATIONLIST_WIDGET_CLOSEBOX = 0,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    29
	STATIONLIST_WIDGET_LIST = 3,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    30
	STATIONLIST_WIDGET_TRAIN =6,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    31
	STATIONLIST_WIDGET_TRUCK,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    32
	STATIONLIST_WIDGET_BUS,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    33
	STATIONLIST_WIDGET_AIRPLANE,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    34
	STATIONLIST_WIDGET_SHIP,
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    35
	STATIONLIST_WIDGET_CARGOSTART = 20,
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    36
	STATIONLIST_WIDGET_NOCARGOWAITING = 12,
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    37
	STATIONLIST_WIDGET_FACILALL = 14,
5271
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    38
	STATIONLIST_WIDGET_CARGOALL,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    39
	STATIONLIST_WIDGET_SORTBY,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    40
	STATIONLIST_WIDGET_SORTCRITERIA,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    41
	STATIONLIST_WIDGET_SORTDROPBTN,
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    42
};
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
    43
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
    44
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
    45
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
    46
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
    47
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
    48
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
    49
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
    50
5293
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    51
/** Draw small boxes of cargo amount and ratings data at the given
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    52
 * coordinates. If amount exceeds 576 units, it is shown 'full', same
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    53
 * goes for the rating: at above 90% orso (224) it is also 'full'
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    54
 * Each cargo-bar is 16 pixels wide and 6 pixels high
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    55
 * Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
    56
 * @param x coordinate to draw the box at
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
    57
 * @param y coordinate to draw the box at
5293
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    58
 * @param type Cargo type
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    59
 * @param amount Cargo amount
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    60
 * @param rating ratings data for that particular cargo */
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    61
static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
{
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6263
diff changeset
    63
	const CargoSpec *cs = GetCargo(type);
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6263
diff changeset
    64
	if (!cs->IsValid()) return;
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6263
diff changeset
    65
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6263
diff changeset
    66
	int colour = cs->rating_colour;
5293
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    67
	uint w = (minu(amount, 576) + 5) / 36;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
5293
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    69
	/* Draw total cargo (limited) on station (fits into 16 pixels) */
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    70
	if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
5293
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    72
	/* Draw a one pixel-wide bar of additional cargo meter, useful
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    73
	 * for stations with only a small amount (<=30) */
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    74
	if (w == 0) {
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    75
		uint rest = amount / 5;
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    76
		if (rest != 0) {
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    77
			w += x;
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    78
			GfxFillRect(w, y + 6 - rest, w, y + 6, colour);
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    79
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6263
diff changeset
    82
	DrawString(x + 1, y, cs->abbrev, 0x10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
5293
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    84
	/* Draw green/red ratings bar (fits into 14 pixels) */
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    85
	y += 8;
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    86
	GfxFillRect(x + 1, y, x + 14, y, 0xB8);
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    87
	rating = minu(rating,  224) / 16;
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
    88
	if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
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
    91
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
    92
	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
    93
	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
    94
	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
    95
	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
    96
	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
    97
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
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
   100
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
   101
static int _internal_sort_order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
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
   103
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
   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;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
	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
   108
	int r;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
4416
e0e9a72882d0 (svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents: 4354
diff changeset
   110
	SetDParam(0, st1->index);
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4896
diff changeset
   111
	GetString(buf1, STR_STATION, lastof(buf1));
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
   112
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
   113
	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
   114
		_last_station = st2;
4416
e0e9a72882d0 (svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents: 4354
diff changeset
   115
		SetDParam(0, st2->index);
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4896
diff changeset
   116
		GetString(_bufcache, STR_STATION, lastof(_bufcache));
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
   117
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   119
	r = strcmp(buf1, _bufcache); // sort by name
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
   120
	return (_internal_sort_order & 1) ? -r : r;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
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
   123
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
   124
{
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   125
	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
   126
	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
   127
	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
   128
}
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
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
   131
{
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   132
	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
   133
	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
   134
	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
   135
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   136
	for (CargoID j = 0; j < NUM_CARGO; j++) {
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
   137
		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
   138
		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
   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
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   141
	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
   142
}
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
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   144
/**
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   145
 * qsort-compatible version of sorting two stations by maximum rating
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   146
 * @param a   First object to be sorted, must be of type (const Station *)
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   147
 * @param b   Second object to be sorted, must be of type (const Station *)
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   148
 * @return    The sort order
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   149
 * @retval >0 a should come before b in the list
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   150
 * @retval <0 b should come before a in the list
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   151
 */
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
   152
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
   153
{
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   154
	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
   155
	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
   156
	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
   157
	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
   158
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   159
	for (CargoID j = 0; j < NUM_CARGO; j++) {
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   160
		if (st1->goods[j].enroute_from != INVALID_STATION) maxr1 = max(maxr1, st1->goods[j].rating);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   161
		if (st2->goods[j].enroute_from != INVALID_STATION) maxr2 = max(maxr2, st2->goods[j].rating);
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
   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
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
	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
   165
}
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
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   167
enum StationListFlags {
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
   168
	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
   169
	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
   170
	SL_REBUILD = 0x04,
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   171
};
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
   172
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   173
DECLARE_ENUM_AS_BIT_SET(StationListFlags);
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   174
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   175
struct plstations_d {
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   176
	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
   177
	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
   178
	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
   179
	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
   180
	uint16 resort_timer;  //was byte refresh_counter;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   181
};
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
   182
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
   183
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   184
void RebuildStationLists()
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
   185
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6252
diff changeset
   186
	BaseWindow *w = 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
   187
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   188
	FOR_ALL_WINDOWS(w) {
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
   189
		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
   190
			WP(w, plstations_d).flags |= SL_REBUILD;
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   191
			w->SetDirty();
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
   192
		}
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
	}
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
}
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
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   196
void ResortStationLists()
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
   197
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6252
diff changeset
   198
	BaseWindow *w = 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
   199
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   200
	FOR_ALL_WINDOWS(w) {
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
   201
		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
   202
			WP(w, plstations_d).flags |= SL_RESORT;
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   203
			w->SetDirty();
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
   204
		}
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
}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   207
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   208
static void BuildStationsList(plstations_d* sl, PlayerID owner, byte facilities, uint32 cargo_filter, bool include_empty)
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
   209
{
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   210
	uint n = 0;
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 222
diff changeset
   211
	const Station *st;
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 222
diff changeset
   212
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
   213
	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
   214
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   215
	/* Create array for sorting */
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5859
diff changeset
   216
	const Station** station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1);
5568
75f13d7bfaed (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5293
diff changeset
   217
	if (station_sort == NULL) 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
   218
5568
75f13d7bfaed (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5293
diff changeset
   219
	DEBUG(misc, 3, "Building station list for player %d", 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
   220
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
	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
   222
		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
   223
			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
   224
				int num_waiting_cargo = 0;
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   225
				for (CargoID j = 0; j < NUM_CARGO; j++) {
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
   226
					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
   227
						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
   228
						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
   229
							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
   230
							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
   231
						}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   232
					}
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
				}
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
   234
				/* stations without waiting cargo */
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   235
				if (num_waiting_cargo == 0 && include_empty) {
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   236
					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
   237
				}
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
			}
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
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
   242
	free((void*)sl->sort_list);
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5859
diff changeset
   243
	sl->sort_list = MallocT<const Station*>(n);
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
   244
	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
   245
	sl->list_length = n;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   247
	for (uint 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
   248
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
   249
	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
   250
	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
   251
	free((void*)station_sort);
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 222
diff changeset
   252
}
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 222
diff changeset
   253
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
   254
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
   255
{
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
   256
	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
   257
		&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
   258
		&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
   259
		&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
   260
		&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
   261
	};
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
   262
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
   263
	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
   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
	_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
   266
	_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
   267
	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
   268
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
   269
	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
   270
	sl->flags &= ~SL_RESORT;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   273
static const uint32 _cargo_filter_max = ~0;
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   274
static uint32 _cargo_filter = _cargo_filter_max;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   275
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6252
diff changeset
   276
static void PlayerStationsWndProc(BaseWindow *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
{
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   278
	const PlayerID owner = (PlayerID)w->window_number;
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
   279
	static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
5859
158718283d16 (svn r8065) -Feature: The station list does now remember the sort settings
celestar
parents: 5838
diff changeset
   280
	static Listing station_sort = {0, 0};
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   281
	static bool include_empty = true;
5859
158718283d16 (svn r8065) -Feature: The station list does now remember the sort settings
celestar
parents: 5838
diff changeset
   282
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
   283
	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
   284
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   285
	switch (e->event) {
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   286
		case WE_CREATE: /* set up resort timer */
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   287
			if (_cargo_filter == _cargo_filter_max) _cargo_filter = _cargo_mask;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   288
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   289
			for (uint i = 0; i < 5; i++) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   290
				if (HASBIT(facilities, i)) w->LowerWidget(i + STATIONLIST_WIDGET_TRAIN);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   291
			}
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   292
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   293
			w->SetWidgetLoweredState(STATIONLIST_WIDGET_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   294
			w->SetWidgetLoweredState(STATIONLIST_WIDGET_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   295
			w->SetWidgetLoweredState(STATIONLIST_WIDGET_NOCARGOWAITING, include_empty);
5271
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
   296
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   297
			sl->sort_list = NULL;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   298
			sl->flags = SL_REBUILD;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   299
			sl->sort_type = station_sort.criteria;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   300
			if (station_sort.order) sl->flags |= SL_ORDER;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   301
			sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   302
			break;
5271
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
   303
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   304
		case WE_PAINT: {
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   305
			BuildStationsList(sl, owner, facilities, _cargo_filter, include_empty);
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   306
			SortStationsList(sl);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   308
			SetVScrollCount(w, sl->list_length);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   310
			/* draw widgets, with player's name in the caption */
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
   311
			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
   312
			SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   313
			SetDParam(1, p->name_2);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   314
			SetDParam(2, w->vscroll.count);
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6240
diff changeset
   315
			w->DrawWidgets();
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
   316
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   317
			/* 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
   318
			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
   319
			/* 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
   320
			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
   321
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   322
			int cg_ofst;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   323
			int x = 89;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   324
			int y = 14;
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
   325
			int xb = 2; ///< offset from left of 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
   326
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   327
			uint i = 0;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   328
			for (CargoID c = 0; c < NUM_CARGO; c++) {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   329
				const CargoSpec *cs = GetCargo(c);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   330
				if (!cs->IsValid()) continue;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   331
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   332
				cg_ofst = HASBIT(_cargo_filter, c) ? 2 : 1;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   333
				GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   334
				DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, 0x10);
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
   335
				x += 14;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   336
				i++;
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
   337
			}
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3554
diff changeset
   338
5292
99fd0bfe7299 (svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents: 5291
diff changeset
   339
			x += 6;
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6246
diff changeset
   340
			cg_ofst = w->IsWidgetLowered(STATIONLIST_WIDGET_NOCARGOWAITING) ? 2 : 1;
5292
99fd0bfe7299 (svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents: 5291
diff changeset
   341
			DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, 16);
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
			x += 14;
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6246
diff changeset
   343
			cg_ofst = w->IsWidgetLowered(STATIONLIST_WIDGET_CARGOALL) ? 2 : 1;
5292
99fd0bfe7299 (svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents: 5291
diff changeset
   344
			DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, 16);
5271
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
   345
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6246
diff changeset
   346
			cg_ofst = w->IsWidgetLowered(STATIONLIST_WIDGET_FACILALL) ? 2 : 1;
5292
99fd0bfe7299 (svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents: 5291
diff changeset
   347
			DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
2026
02dfa0aa2c2f (svn r2535) Tabs
tron
parents: 1962
diff changeset
   349
			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
   350
				DrawString(xb, 40, STR_304A_NONE, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   353
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   354
			int max = min(w->vscroll.pos + w->vscroll.cap, sl->list_length);
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
   355
			y = 40; // start of the list-widget
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   357
			for (int i = w->vscroll.pos; i < max; ++i) { // do until max number of stations of owner
5293
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
   358
				const Station *st = sl->sort_list[i];
2630
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   359
				int x;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
5293
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
   361
				assert(st->xy != 0);
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
   362
				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
   363
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   364
				SetDParam(0, st->index);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   365
				SetDParam(1, st->facilities);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
				x = DrawString(xb, y, STR_3049_0, 0) + 5;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
   368
				/* show cargo waiting and station ratings */
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   369
				for (CargoID j = 0; j < NUM_CARGO; j++) {
5293
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
   370
					uint amount = GB(st->goods[j].waiting_acceptance, 0, 12);
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
   371
					if (amount != 0) {
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
   372
						StationsWndShowStationRating(x, y, j, amount, st->goods[j].rating);
4d59f970b2fe (svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents: 5292
diff changeset
   373
						x += 20;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
				y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
			}
4268
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   378
			break;
78373df5a67a (svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents: 4261
diff changeset
   379
		}
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
   380
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   381
		case WE_CLICK:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   382
			switch (e->we.click.widget) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   383
				case STATIONLIST_WIDGET_LIST: {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   384
					uint32 id_v = (e->we.click.pt.y - 41) / 10;
5271
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
   385
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   386
					if (id_v >= w->vscroll.cap) return; // click out of bounds
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   387
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   388
					id_v += w->vscroll.pos;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   389
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   390
					if (id_v >= sl->list_length) return; // click out of list bound
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   391
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   392
					const Station *st = sl->sort_list[id_v];
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   393
					assert(st->owner == owner);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   394
					ScrollMainWindowToTile(st->xy);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   395
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   396
				}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   397
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   398
				case STATIONLIST_WIDGET_TRAIN:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   399
				case STATIONLIST_WIDGET_TRUCK:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   400
				case STATIONLIST_WIDGET_BUS:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   401
				case STATIONLIST_WIDGET_AIRPLANE:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   402
				case STATIONLIST_WIDGET_SHIP:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   403
					if (_ctrl_pressed) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   404
						TOGGLEBIT(facilities, e->we.click.widget - STATIONLIST_WIDGET_TRAIN);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   405
						w->ToggleWidgetLoweredState(e->we.click.widget);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   406
					} else {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   407
						for (uint i = 0; facilities != 0; i++, facilities >>= 1) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   408
							if (HASBIT(facilities, 0)) w->RaiseWidget(i + STATIONLIST_WIDGET_TRAIN);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   409
						}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   410
						SETBIT(facilities, e->we.click.widget - STATIONLIST_WIDGET_TRAIN);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   411
						w->LowerWidget(e->we.click.widget);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   412
					}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   413
					w->SetWidgetLoweredState(STATIONLIST_WIDGET_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   414
					sl->flags |= SL_REBUILD;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   415
					w->SetDirty();
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   416
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   417
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   418
				case STATIONLIST_WIDGET_FACILALL:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   419
					for (uint i = 0; i < 5; i++) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   420
						w->LowerWidget(i + STATIONLIST_WIDGET_TRAIN);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   421
					}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   422
					w->LowerWidget(STATIONLIST_WIDGET_FACILALL);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   423
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   424
					facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   425
					sl->flags |= SL_REBUILD;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   426
					w->SetDirty();
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   427
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   428
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   429
				case STATIONLIST_WIDGET_CARGOALL: {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   430
					uint i = 0;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   431
					for (CargoID c = 0; c < NUM_CARGO; c++) {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   432
						if (!GetCargo(c)->IsValid()) continue;
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   433
						w->LowerWidget(i + STATIONLIST_WIDGET_CARGOSTART);
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   434
						i++;
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   435
					}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   436
					w->LowerWidget(STATIONLIST_WIDGET_NOCARGOWAITING);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   437
					w->LowerWidget(STATIONLIST_WIDGET_CARGOALL);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   438
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   439
					_cargo_filter = _cargo_mask;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   440
					include_empty = true;
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   441
					sl->flags |= SL_REBUILD;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   442
					w->SetDirty();
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   443
					break;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   444
				}
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   445
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   446
				case STATIONLIST_WIDGET_SORTBY: /*flip sorting method asc/desc*/
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   447
					sl->flags ^= SL_ORDER; //DESC-flag
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   448
					station_sort.order = GB(sl->flags, 0, 1);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   449
					sl->flags |= SL_RESORT;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   450
					w->flash_timeout = 5;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   451
					w->LowerWidget(STATIONLIST_WIDGET_SORTBY);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   452
					w->SetDirty();
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   453
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   454
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   455
				case STATIONLIST_WIDGET_SORTCRITERIA:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   456
				case STATIONLIST_WIDGET_SORTDROPBTN: /* select sorting criteria dropdown menu */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   457
					w->ShowDropDownMenu(_station_sort_listing, sl->sort_type, STATIONLIST_WIDGET_SORTDROPBTN, 0, 0);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   458
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   459
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   460
				case STATIONLIST_WIDGET_NOCARGOWAITING:
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   461
					if (_ctrl_pressed) {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   462
						include_empty = !include_empty;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   463
						w->ToggleWidgetLoweredState(STATIONLIST_WIDGET_NOCARGOWAITING);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   464
					} else {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   465
						for (uint i = STATIONLIST_WIDGET_CARGOSTART; i < w->widget_count; i++) {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   466
							w->RaiseWidget(i);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   467
						}
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   468
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   469
						_cargo_filter = 0;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   470
						include_empty = true;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   471
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   472
						w->LowerWidget(STATIONLIST_WIDGET_NOCARGOWAITING);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   473
					}
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   474
					sl->flags |= SL_REBUILD;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   475
					w->SetWidgetLoweredState(STATIONLIST_WIDGET_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   476
					w->SetDirty();
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   477
					break;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   478
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   479
				default:
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   480
					if (e->we.click.widget >= STATIONLIST_WIDGET_CARGOSTART) { //change cargo_filter
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   481
						/* Determine the selected cargo type */
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   482
						CargoID c;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   483
						int i = 0;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   484
						for (c = 0; c < NUM_CARGO; c++) {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   485
							if (!GetCargo(c)->IsValid()) continue;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   486
							if (e->we.click.widget - STATIONLIST_WIDGET_CARGOSTART == i) break;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   487
							i++;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   488
						}
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   489
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   490
						if (_ctrl_pressed) {
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   491
							TOGGLEBIT(_cargo_filter, c);
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   492
							w->ToggleWidgetLoweredState(e->we.click.widget);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   493
						} else {
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   494
							for (uint i = STATIONLIST_WIDGET_CARGOSTART; i < w->widget_count; i++) {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   495
								w->RaiseWidget(i);
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   496
							}
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   497
							w->RaiseWidget(STATIONLIST_WIDGET_NOCARGOWAITING);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   498
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   499
							_cargo_filter = 0;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   500
							include_empty = false;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   501
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   502
							SETBIT(_cargo_filter, c);
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   503
							w->LowerWidget(e->we.click.widget);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   504
						}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   505
						sl->flags |= SL_REBUILD;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   506
						w->SetWidgetLoweredState(STATIONLIST_WIDGET_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   507
						w->SetDirty();
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   508
					}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   509
					break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   510
			}
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
   511
			break;
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   512
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   513
		case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   514
			if (sl->sort_type != e->we.dropdown.index) {
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
   515
				/* value has changed -> resort */
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   516
				sl->sort_type = e->we.dropdown.index;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   517
				station_sort.criteria = sl->sort_type;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   518
				sl->flags |= SL_RESORT;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   519
			}
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   520
			w->SetDirty();
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
   521
			break;
5271
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
   522
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   523
		case WE_TICK:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   524
			if (--sl->resort_timer == 0) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   525
				DEBUG(misc, 3, "Periodic rebuild station list player %d", owner);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   526
				sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
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
   527
				sl->flags |= SL_REBUILD;
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   528
				w->SetDirty();
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
   529
			}
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   530
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   532
		case WE_TIMEOUT:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   533
			w->RaiseWidget(STATIONLIST_WIDGET_SORTBY);
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   534
			w->SetDirty();
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   535
			break;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   536
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   537
		case WE_RESIZE:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   538
			w->vscroll.cap += e->we.sizing.diff.y / 10;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   539
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6252
diff changeset
   543
static const OldWidget _player_stations_widgets[] = {
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   544
{   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
   545
{    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
   546
{  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
   547
{      WWT_PANEL,     RESIZE_RB,    14,     0,   345,    37,   161, 0x0,               STR_3057_STATION_NAMES_CLICK_ON},
5128
c75525088fb9 (svn r7209) -Codechange: Alter position of scroll bar in the station list; the filter line isn't scrollable...
peter1138
parents: 5124
diff changeset
   548
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   346,   357,    37,   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
   549
{  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
   550
//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
   551
{    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
   552
{    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
   553
{    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
   554
{    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
   555
{    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
   556
//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
   557
{      WWT_PANEL,   RESIZE_NONE,    14,    83,    88,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   558
{      WWT_PANEL,   RESIZE_NONE,    14,    89,   102,    14,    24, 0x0,               STR_NO_WAITING_CARGO},
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   559
{      WWT_PANEL,  RESIZE_RIGHT,    14,   117,   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
   560
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   561
//14
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
   562
{      WWT_PANEL,   RESIZE_NONE,    14,    70,    83,    14,    24, 0x0,               STR_SELECT_ALL_FACILITIES},
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   563
{      WWT_PANEL,   RESIZE_NONE,    14,   103,   116,    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
   564
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   565
//16
5271
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
   566
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    80,    25,    36, STR_SORT_BY,       STR_SORT_ORDER_TIP},
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
   567
{      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
   568
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   233,   243,    25,    36, STR_0225,          STR_SORT_CRITERIA_TIP},
5128
c75525088fb9 (svn r7209) -Codechange: Alter position of scroll bar in the station list; the filter line isn't scrollable...
peter1138
parents: 5124
diff changeset
   569
{      WWT_PANEL,  RESIZE_RIGHT,    14,   244,   357,    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
   570
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
static const WindowDesc _player_stations_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5038
diff changeset
   574
	WDP_AUTO, WDP_AUTO, 358, 162,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5996
diff changeset
   575
	WC_STATION_LIST, WC_NONE,
5271
419c6746fd90 (svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents: 5247
diff changeset
   576
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
	_player_stations_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
	PlayerStationsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2186
diff changeset
   582
void ShowPlayerStations(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
{
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4938
diff changeset
   584
	if (!IsValidPlayer(player)) return;
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4938
diff changeset
   585
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   586
	BaseWindow *w = BaseWindow::AllocateFront(&_player_stations_desc, player);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   587
	if (w == NULL) return;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   588
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   589
	w->caption_color = (byte)w->window_number;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   590
	w->vscroll.cap = 12;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   591
	w->resize.step_height = 10;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   592
	w->resize.height = w->Height() - 10 * 7; // minimum if 5 in the list
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   593
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   594
	/* Add cargo filter buttons */
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   595
	uint num_active = 0;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   596
	for (CargoID c = 0; c < NUM_CARGO; c++) {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   597
		if (GetCargo(c)->IsValid()) num_active++;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   598
	}
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   599
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   600
	w->widget_count += num_active;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   601
	w->widget = ReallocT(w->widget, w->widget_count + 1);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   602
	w->widget[w->widget_count].type = WWT_LAST;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   603
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   604
	uint i = 0;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   605
	for (CargoID c = 0; c < NUM_CARGO; c++) {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   606
		if (!GetCargo(c)->IsValid()) continue;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   607
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   608
		OldWidget *wi = &w->widget[STATIONLIST_WIDGET_CARGOSTART + i];
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   609
		wi->type     = WWT_PANEL;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   610
		wi->m_display_flags = RESIZE_NONE;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   611
		wi->color    = 14;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   612
		wi->left     = 89 + i * 14;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   613
		wi->right    = wi->left + 13;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   614
		wi->top      = 14;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   615
		wi->bottom   = 24;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   616
		wi->data     = 0;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   617
		wi->tooltips = STR_USE_CTRL_TO_SELECT_MORE;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   618
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   619
		if (HASBIT(_cargo_filter, c)) w->LowerWidget(STATIONLIST_WIDGET_CARGOSTART + i);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   620
		i++;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   621
	}
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   622
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   623
	w->widget[STATIONLIST_WIDGET_NOCARGOWAITING].left += num_active * 14;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   624
	w->widget[STATIONLIST_WIDGET_NOCARGOWAITING].right += num_active * 14;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   625
	w->widget[STATIONLIST_WIDGET_CARGOALL].left += num_active * 14;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   626
	w->widget[STATIONLIST_WIDGET_CARGOALL].right += num_active * 14;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   627
	w->widget[13].left += num_active * 14;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   628
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   629
	if (num_active > 15) {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   630
		/* Resize and fix the minimum width, if necessary */
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   631
		w->Resize((num_active - 15) * 14, 0);
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   632
		w->resize.width = w->Width();
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   633
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   635
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6252
diff changeset
   636
static const OldWidget _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
   637
{   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
   638
{    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
   639
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   237,   248,     0,    13, 0x0,               STR_STICKY_BUTTON},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   640
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   236,    14,    65, 0x0,               STR_NULL},
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   641
{  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
   642
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,               STR_NULL},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   643
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   248,    66,   197, 0x0,               STR_NULL},
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   644
{ 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
   645
{ 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
   646
{ 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
   647
{ 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
   648
{ 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
   649
{ 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
   650
{ 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
   651
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   653
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6252
diff changeset
   654
static const OldWidget _station_view_widgets[] = {
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   655
{   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
   656
{    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
   657
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   237,   248,     0,    13, 0x0,               STR_STICKY_BUTTON},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   658
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   236,    14,    65, 0x0,               STR_NULL},
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   659
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   237,   248,    14,    65, 0x0,               STR_0190_SCROLL_BAR_SCROLLS_LIST},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   660
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   248,    66,    97, 0x0,               STR_NULL},
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 2725
diff changeset
   661
{      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
   662
{ 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
   663
{ 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
   664
{ 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
   665
{ 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
   666
{ 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
   667
{ 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
   668
{ 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
   669
{   WIDGETS_END},
0
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
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   672
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   673
static void DrawCargoIcons(CargoID i, uint waiting, int x, int y)
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   674
{
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   675
	uint num = min((waiting + 5) / 10, 23);
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   676
	if (num == 0) return;
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   677
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   678
	const CargoSpec *cs = GetCargo(i);
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   679
	SpriteID sprite;
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   680
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   681
	if (cs->sprite == 0xFFFF) {
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   682
		/* A value of 0xFFFF indicates we should draw a custom icon */
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   683
		sprite = GetCustomCargoSprite(cs);
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   684
	} else {
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   685
		sprite = cs->sprite;
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   686
	}
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   687
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   688
	if (sprite == 0) return;
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   689
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   690
	do {
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   691
		DrawSprite(sprite, PAL_NONE, x, y);
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   692
		x += 10;
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   693
	} while (--num);
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   694
}
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   695
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6252
diff changeset
   696
static void DrawStationViewWindow(BaseWindow *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
{
2630
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   698
	StationID station_id = w->window_number;
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   699
	const Station* st = GetStation(station_id);
35249d2ded3e (svn r3172) static, const
tron
parents: 2549
diff changeset
   700
	uint num;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
	int x,y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
	int pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   703
	StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
	num = 1;
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   706
	for (CargoID 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
   707
		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
   708
			num++;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   709
			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
   710
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
	SetVScrollCount(w, num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6242
diff changeset
   714
	w->SetWidgetDisabledState( 9, st->owner != _local_player);
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6242
diff changeset
   715
	w->SetWidgetDisabledState(10, !(st->facilities & FACIL_TRAIN));
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6242
diff changeset
   716
	w->SetWidgetDisabledState(11, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6242
diff changeset
   717
	w->SetWidgetDisabledState(12, !(st->facilities & FACIL_AIRPORT));
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6242
diff changeset
   718
	w->SetWidgetDisabledState(13, !(st->facilities & FACIL_DOCK));
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   719
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   720
	SetDParam(0, st->index);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   721
	SetDParam(1, st->facilities);
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6240
diff changeset
   722
	w->DrawWidgets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   723
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
	x = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
	y = 15;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   726
	pos = w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   727
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   728
	if (--pos < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   729
		str = STR_00D0_NOTHING;
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   730
		for (CargoID 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
   731
			if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) str = STR_EMPTY;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   732
		}
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   733
		SetDParam(0, str);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   734
		DrawString(x, y, STR_0008_WAITING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   735
		y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   738
	for (CargoID i = 0; i < NUM_CARGO && pos > -5; i++) {
2504
7c27fc230cda (svn r3030) More work for GB/SB, this time concerning the waiting_acceptance attribute of stations
tron
parents: 2498
diff changeset
   739
		uint waiting = GB(st->goods[i].waiting_acceptance, 0, 12);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   740
		if (waiting == 0) continue;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   741
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   742
		if (st->goods[i].enroute_from == station_id) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
			if (--pos < 0) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   744
				DrawCargoIcons(i, waiting, x, y);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   745
				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
   746
				SetDParam(0, i);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
				DrawStringRightAligned(x + 234, y, STR_0009, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   748
				y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   749
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   750
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
			/* enroute */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   752
			if (--pos < 0) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   753
				DrawCargoIcons(i, waiting, x, y);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   754
				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
   755
				SetDParam(0, i);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   756
				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
   757
				y += 10;
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
			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
   761
				SetDParam(0, st->goods[i].enroute_from);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
				DrawStringRightAligned(x + 234, y, STR_000B, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   763
				y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   764
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   765
		}
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   766
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   767
6240
8d4ea2d6befc (svn r8699) [cpp_gui] -Cleanup: removed the word Window from some Window method names as just being Winddow methods indicates that it's working on a window
bjarni
parents: 6239
diff changeset
   768
	if (w->IsOfPrototype(_station_view_widgets)) {
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   769
		char *b = _userstring;
5038
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   770
		bool first = true;
1329
a8a0d60b0a8e (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
   771
1553
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1474
diff changeset
   772
		b = InlineString(b, STR_000C_ACCEPTS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   774
		for (CargoID i = 0; i < NUM_CARGO; i++) {
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   775
			if (b >= endof(_userstring) - 5 - 1) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   776
			if (st->goods[i].waiting_acceptance & 0x8000) {
5038
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   777
				if (first) {
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   778
					first = false;
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   779
				} else {
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   780
					/* Add a comma if this is not the first item */
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   781
					*b++ = ',';
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   782
					*b++ = ' ';
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   783
				}
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6263
diff changeset
   784
				b = InlineString(b, GetCargo(i)->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   785
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   786
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   787
5038
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   788
		/* If first is still true then no cargo is accepted */
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   789
		if (first) b = InlineString(b, STR_00D0_NOTHING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   790
5038
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   791
		*b = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   792
		DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   793
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   794
		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
   795
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   796
		y = 77;
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   797
		for (CargoID i = 0; i < NUM_CARGO; i++) {
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   798
			const CargoSpec *cs = GetCargo(i);
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   799
			if (!cs->IsValid()) continue;
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   800
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   801
			const GoodsEntry *ge = &st->goods[i];
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   802
			if (ge->enroute_from == INVALID_STATION) continue;
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   803
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   804
			SetDParam(0, cs->name);
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   805
			SetDParam(2, ge->rating * 101 >> 8);
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   806
			SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5));
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   807
			DrawString(8, y, STR_303D, 0);
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   808
			y += 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   810
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   811
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   812
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   813
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6252
diff changeset
   814
static void StationViewWndProc(BaseWindow *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2638
diff changeset
   816
	switch (e->event) {
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   817
		case WE_PAINT:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   818
			DrawStationViewWindow(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   819
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   820
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   821
		case WE_CLICK:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   822
			switch (e->we.click.widget) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   823
				case 7:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   824
					ScrollMainWindowToTile(GetStation(w->window_number)->xy);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   825
					break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   826
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   827
				case 8:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   828
					w->SetDirty();
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   829
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   830
					/* toggle height/widget set */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   831
					if (w->IsOfPrototype(_station_view_expanded_widgets)) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   832
						w->AssignWidget(_station_view_widgets);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   833
						w->SetHeight(110);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   834
					} else {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   835
						w->AssignWidget(_station_view_expanded_widgets);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   836
						w->SetHeight(210);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   837
					}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   838
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   839
					w->SetDirty();
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   840
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   841
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   842
				case 9:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   843
					SetDParam(0, w->window_number);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   844
					ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, w, CS_ALPHANUMERAL);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   845
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   846
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   847
				case 10: { /* Show a list of scheduled trains to this station */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   848
					const Station *st = GetStation(w->window_number);
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   849
					ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)w->window_number);
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   850
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   851
				}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   852
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   853
				case 11: { /* Show a list of scheduled road-vehicles to this station */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   854
					const Station *st = GetStation(w->window_number);
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   855
					ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)w->window_number);
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   856
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   857
				}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   858
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   859
				case 12: { /* Show a list of scheduled aircraft to this station */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   860
					const Station *st = GetStation(w->window_number);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   861
					/* Since oilrigs have no owners, show the scheduled aircraft of current player */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   862
					PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   863
					ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)w->window_number);
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   864
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   865
				}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   866
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   867
				case 13: { /* Show a list of scheduled ships to this station */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   868
					const Station *st = GetStation(w->window_number);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   869
					/* Since oilrigs/bouys have no owners, show the scheduled ships of current player */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   870
					PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   871
					ShowVehicleListWindow(owner, VEH_SHIP, (StationID)w->window_number);
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   872
					break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   873
				}
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 817
diff changeset
   874
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   875
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   876
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   877
		case WE_ON_EDIT_TEXT:
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   878
			if (e->we.edittext.str[0] != '\0') {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   879
				_cmd_text = e->we.edittext.str;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   880
				DoCommandP(0, w->window_number, 0, NULL,
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   881
					CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION));
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   882
			}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   883
			break;
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   884
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   885
		case WE_DESTROY: {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   886
			WindowNumber wno =
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   887
				(w->window_number << 16) | GetStation(w->window_number)->owner;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   888
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   889
			DeleteWindowById(WC_TRAINS_LIST, wno);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   890
			DeleteWindowById(WC_ROADVEH_LIST, wno);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   891
			DeleteWindowById(WC_SHIPS_LIST, wno);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   892
			DeleteWindowById(WC_AIRCRAFT_LIST, wno);
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   893
			break;
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 534
diff changeset
   894
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   895
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   896
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   897
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   898
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   899
static const WindowDesc _station_view_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5038
diff changeset
   900
	WDP_AUTO, WDP_AUTO, 249, 110,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5996
diff changeset
   901
	WC_STATION_VIEW, WC_NONE,
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
   902
	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
   903
	_station_view_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   904
	StationViewWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   905
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   906
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
   907
void ShowStationViewWindow(StationID station)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   908
{
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   909
	BaseWindow *w = BaseWindow::AllocateFront(&_station_view_desc, station);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   910
	if (w == NULL) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   911
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   912
	PlayerID owner = GetStation(w->window_number)->owner;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   913
	if (owner != OWNER_NONE) w->caption_color = owner;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
   914
	w->vscroll.cap = 5;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   915
}