author | rubidium |
Thu, 17 Jul 2008 20:13:01 +0000 | |
changeset 11161 | 7d0fac8f14cd |
parent 11157 | a0173588b15e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10411
diff
changeset
|
3 |
/** @file station_gui.cpp The GUI for stations. */ |
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6691
diff
changeset
|
4 |
|
0 | 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" |
0 | 8 |
#include "gui.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
9 |
#include "window_gui.h" |
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
10 |
#include "textbuf_gui.h" |
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9258
diff
changeset
|
11 |
#include "station_base.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8720
diff
changeset
|
12 |
#include "player_func.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8610
diff
changeset
|
13 |
#include "economy_func.h" |
0 | 14 |
#include "town.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8610
diff
changeset
|
15 |
#include "command_func.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
16 |
#include "variables.h" |
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
17 |
#include "vehicle_gui.h" |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
18 |
#include "cargotype.h" |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
19 |
#include "station_gui.h" |
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9258
diff
changeset
|
20 |
#include "station_func.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8605
diff
changeset
|
21 |
#include "strings_func.h" |
8626
440dfcd14c4a
(svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents:
8617
diff
changeset
|
22 |
#include "core/alloc_func.hpp" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
23 |
#include "window_func.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8675
diff
changeset
|
24 |
#include "viewport_func.h" |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8675
diff
changeset
|
25 |
#include "gfx_func.h" |
8780
6f3f3ec6c69a
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
8764
diff
changeset
|
26 |
#include "widgets/dropdown_func.h" |
9283
624272490f5a
(svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents:
9281
diff
changeset
|
27 |
#include "newgrf_cargo.h" |
10484
e8beb2845f13
(svn r13027) -Codechange: use StrEmpty instead of arr[0] == '\0' and remove the need for WE_ON_EDIT_TEXT_CANCEL.
rubidium
parents:
10462
diff
changeset
|
28 |
#include "string_func.h" |
5271
419c6746fd90
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
29 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
30 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
31 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
32 |
|
8764
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
33 |
bool _station_show_coverage; |
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
34 |
|
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
35 |
/** |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
36 |
* Draw small boxes of cargo amount and ratings data at the given |
5293
4d59f970b2fe
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
37 |
* 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
|
38 |
* goes for the rating: at above 90% orso (224) it is also 'full' |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
39 |
* |
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6691
diff
changeset
|
40 |
* @param x coordinate to draw the box at |
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6691
diff
changeset
|
41 |
* @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
|
42 |
* @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
|
43 |
* @param amount Cargo amount |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
44 |
* @param rating ratings data for that particular cargo |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
45 |
* |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
46 |
* @note Each cargo-bar is 16 pixels wide and 6 pixels high |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
47 |
* @note Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
48 |
*/ |
5293
4d59f970b2fe
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
49 |
static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating) |
0 | 50 |
{ |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
51 |
static const uint units_full = 576; ///< number of units to show station as 'full' |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
52 |
static const uint rating_full = 224; ///< rating needed so it is shown as 'full' |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
53 |
|
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
54 |
const CargoSpec *cs = GetCargo(type); |
6448
a749c78812a7
(svn r8858) -Codechange: Replace magic number test with class method for determining if a cargo is valid/active.
peter1138
parents:
6417
diff
changeset
|
55 |
if (!cs->IsValid()) return; |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
56 |
|
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
57 |
int colour = cs->rating_colour; |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
58 |
uint w = (minu(amount, units_full) + 5) / 36; |
0 | 59 |
|
5293
4d59f970b2fe
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
60 |
/* 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
|
61 |
if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour); |
0 | 62 |
|
5293
4d59f970b2fe
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
63 |
/* 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
|
64 |
* 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
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
} |
0 | 71 |
} |
72 |
||
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7970
diff
changeset
|
73 |
DrawString(x + 1, y, cs->abbrev, TC_BLACK); |
0 | 74 |
|
5293
4d59f970b2fe
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
75 |
/* 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
|
76 |
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
|
77 |
GfxFillRect(x + 1, y, x + 14, y, 0xB8); |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
78 |
rating = minu(rating, rating_full) / 16; |
5293
4d59f970b2fe
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
79 |
if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0); |
0 | 80 |
} |
81 |
||
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
82 |
typedef GUIList<const Station*> GUIStationList; |
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
|
83 |
|
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
84 |
/** |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
85 |
* The list of stations per player. |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
86 |
*/ |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
87 |
class PlayerStationsWindow : public Window |
0 | 88 |
{ |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
89 |
protected: |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
90 |
/* Runtime saved values */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
91 |
static Listing last_sorting; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
92 |
static byte facilities; // types of stations of interest |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
93 |
static bool include_empty; // whether we should include stations without waiting cargo |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
94 |
static const uint32 cargo_filter_max; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
95 |
static uint32 cargo_filter; // bitmap of cargo types to include |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
96 |
static const Station *last_station; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
97 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
98 |
/* Constants for sorting stations */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
99 |
static const StringID sorter_names[]; |
10742 | 100 |
static GUIStationList::SortFunction *const sorter_funcs[]; |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
101 |
|
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
102 |
GUIStationList stations; |
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
103 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
104 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
105 |
/** |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
106 |
* (Re)Build station list |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
107 |
* |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
108 |
* @param owner player whose stations are to be in list |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
109 |
*/ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
110 |
void BuildStationsList(const PlayerID owner) |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
111 |
{ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
112 |
if (!this->stations.NeedRebuild()) return; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
113 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
114 |
DEBUG(misc, 3, "Building station list for player %d", owner); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
115 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
116 |
this->stations.Clear(); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
117 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
118 |
const Station *st; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
119 |
FOR_ALL_STATIONS(st) { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
120 |
if (st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy() && HasStationInUse(st->index, owner))) { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
121 |
if (this->facilities & st->facilities) { // only stations with selected facilities |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
122 |
int num_waiting_cargo = 0; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
123 |
for (CargoID j = 0; j < NUM_CARGO; j++) { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
124 |
if (!st->goods[j].cargo.Empty()) { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
125 |
num_waiting_cargo++; // count number of waiting cargo |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
126 |
if (HasBit(this->cargo_filter, j)) { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
127 |
*this->stations.Append() = st; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
128 |
break; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
129 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
130 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
131 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
132 |
/* stations without waiting cargo */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
133 |
if (num_waiting_cargo == 0 && this->include_empty) { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
134 |
*this->stations.Append() = st; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
135 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
136 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
137 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
138 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
139 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
140 |
this->stations.Compact(); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
141 |
this->stations.RebuildDone(); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
142 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
143 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
144 |
/** Sort stations by their name */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
145 |
static int CDECL StationNameSorter(const Station* const *a, const Station* const *b) |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
146 |
{ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
147 |
static char buf_cache[64]; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
148 |
char buf[64]; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
149 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
150 |
SetDParam(0, (*a)->index); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
151 |
GetString(buf, STR_STATION, lastof(buf)); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
152 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
153 |
if (*b != last_station) { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
154 |
last_station = *b; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
155 |
SetDParam(0, (*b)->index); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
156 |
GetString(buf_cache, STR_STATION, lastof(buf_cache)); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
157 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
158 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
159 |
return strcmp(buf, buf_cache); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
160 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
161 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
162 |
/** Sort stations by their type */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
163 |
static int CDECL StationTypeSorter(const Station* const *a, const Station* const *b) |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
164 |
{ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
165 |
return (*a)->facilities - (*b)->facilities; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
166 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
167 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
168 |
/** Sort stations by their waiting cargo */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
169 |
static int CDECL StationWaitingSorter(const Station* const *a, const Station* const *b) |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
170 |
{ |
11060
88faea407e28
(svn r13617) -Codechange: calculate the diff in StationWaitingSorter directly
skidd13
parents:
10752
diff
changeset
|
171 |
Money diff = 0; |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
172 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
173 |
for (CargoID j = 0; j < NUM_CARGO; j++) { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
174 |
if (!HasBit(cargo_filter, j)) continue; |
11060
88faea407e28
(svn r13617) -Codechange: calculate the diff in StationWaitingSorter directly
skidd13
parents:
10752
diff
changeset
|
175 |
if (!(*a)->goods[j].cargo.Empty()) diff += GetTransportedGoodsIncome((*a)->goods[j].cargo.Count(), 20, 50, j); |
88faea407e28
(svn r13617) -Codechange: calculate the diff in StationWaitingSorter directly
skidd13
parents:
10752
diff
changeset
|
176 |
if (!(*b)->goods[j].cargo.Empty()) diff -= GetTransportedGoodsIncome((*b)->goods[j].cargo.Count(), 20, 50, j); |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
177 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
178 |
|
11060
88faea407e28
(svn r13617) -Codechange: calculate the diff in StationWaitingSorter directly
skidd13
parents:
10752
diff
changeset
|
179 |
return ClampToI32(diff); |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
180 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
181 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
182 |
/** Sort stations by their rating */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
183 |
static int CDECL StationRatingMaxSorter(const Station* const *a, const Station* const *b) |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
184 |
{ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
185 |
byte maxr1 = 0; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
186 |
byte maxr2 = 0; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
187 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
188 |
for (CargoID j = 0; j < NUM_CARGO; j++) { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
189 |
if (HasBit((*a)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr1 = max(maxr1, (*a)->goods[j].rating); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
190 |
if (HasBit((*b)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr2 = max(maxr2, (*b)->goods[j].rating); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
191 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
192 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
193 |
return maxr1 - maxr2; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
194 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
195 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
196 |
/** Sort the stations list */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
197 |
void SortStationsList() |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
198 |
{ |
10736
e3111a03f9c2
(svn r13286) -Codechange: GUIList Sort returns now if the list sequence has been altered
skidd13
parents:
10735
diff
changeset
|
199 |
if (!this->stations.Sort()) return; |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
200 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
201 |
/* Reset name sorter sort cache */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
202 |
this->last_station = NULL; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
203 |
|
10749
b8ac8a8e27c4
(svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13
parents:
10742
diff
changeset
|
204 |
/* Set the modified widget dirty */ |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
205 |
this->InvalidateWidget(SLW_LIST); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
206 |
} |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
207 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
208 |
public: |
10525
da5bc725cda4
(svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
rubidium
parents:
10511
diff
changeset
|
209 |
PlayerStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
210 |
{ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
211 |
this->caption_color = (byte)this->window_number; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
212 |
this->vscroll.cap = 12; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
213 |
this->resize.step_height = 10; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
214 |
this->resize.height = this->height - 10 * 7; // minimum if 5 in the list |
8834
ef15cacd6894
(svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents:
8780
diff
changeset
|
215 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
216 |
/* Add cargo filter buttons */ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
217 |
uint num_active = 0; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
218 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
219 |
if (GetCargo(c)->IsValid()) num_active++; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
220 |
} |
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
|
221 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
222 |
this->widget_count += num_active; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
223 |
this->widget = ReallocT(this->widget, this->widget_count + 1); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
224 |
this->widget[this->widget_count].type = WWT_LAST; |
6597
e4ce4b1aa3bf
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6586
diff
changeset
|
225 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
226 |
uint i = 0; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
227 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
228 |
if (!GetCargo(c)->IsValid()) continue; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
229 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
230 |
Widget *wi = &this->widget[SLW_CARGOSTART + i]; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
231 |
wi->type = WWT_PANEL; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
232 |
wi->display_flags = RESIZE_NONE; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
233 |
wi->color = 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
234 |
wi->left = 89 + i * 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
235 |
wi->right = wi->left + 13; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
236 |
wi->top = 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
237 |
wi->bottom = 24; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
238 |
wi->data = 0; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
239 |
wi->tooltips = STR_USE_CTRL_TO_SELECT_MORE; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
240 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
241 |
if (HasBit(this->cargo_filter, c)) this->LowerWidget(SLW_CARGOSTART + i); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
242 |
i++; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
243 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
244 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
245 |
this->widget[SLW_NOCARGOWAITING].left += num_active * 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
246 |
this->widget[SLW_NOCARGOWAITING].right += num_active * 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
247 |
this->widget[SLW_CARGOALL].left += num_active * 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
248 |
this->widget[SLW_CARGOALL].right += num_active * 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
249 |
this->widget[SLW_PAN_RIGHT].left += num_active * 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
250 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
251 |
if (num_active > 15) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
252 |
/* Resize and fix the minimum width, if necessary */ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
253 |
ResizeWindow(this, (num_active - 15) * 14, 0); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
254 |
this->resize.width = this->width; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
255 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
256 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
257 |
if (this->cargo_filter == this->cargo_filter_max) this->cargo_filter = _cargo_mask; |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
258 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
259 |
for (uint i = 0; i < 5; i++) { |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
260 |
if (HasBit(this->facilities, i)) this->LowerWidget(i + SLW_TRAIN); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
261 |
} |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
262 |
this->SetWidgetLoweredState(SLW_FACILALL, this->facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK)); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
263 |
this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
264 |
this->SetWidgetLoweredState(SLW_NOCARGOWAITING, this->include_empty); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
265 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
266 |
this->stations.SetListing(this->last_sorting); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
267 |
this->stations.SetSortFuncs(this->sorter_funcs); |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
268 |
this->stations.ForceRebuild(); |
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
269 |
this->stations.NeedResort(); |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
270 |
this->SortStationsList(); |
10681
3aa3de4d448b
(svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents:
10641
diff
changeset
|
271 |
|
10749
b8ac8a8e27c4
(svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13
parents:
10742
diff
changeset
|
272 |
this->widget[SLW_SORTDROPBTN].data = this->sorter_names[this->stations.SortType()]; |
b8ac8a8e27c4
(svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13
parents:
10742
diff
changeset
|
273 |
|
10681
3aa3de4d448b
(svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents:
10641
diff
changeset
|
274 |
this->FindWindowPlacementAndResize(desc); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
275 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
276 |
|
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
277 |
~PlayerStationsWindow() |
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
278 |
{ |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
279 |
this->last_sorting = this->stations.GetListing(); |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
280 |
} |
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
281 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
282 |
virtual void OnPaint() |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
283 |
{ |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
284 |
const PlayerID owner = (PlayerID)this->window_number; |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
285 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
286 |
this->BuildStationsList(owner); |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
287 |
this->SortStationsList(); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
288 |
|
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
289 |
SetVScrollCount(this, this->stations.Length()); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
290 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
291 |
/* draw widgets, with player's name in the caption */ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
292 |
SetDParam(0, owner); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
293 |
SetDParam(1, this->vscroll.count); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
294 |
|
10595
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10536
diff
changeset
|
295 |
this->DrawWidgets(); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
296 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
297 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
298 |
this->DrawSortButtonState(SLW_SORTBY, this->stations.IsDescSortOrder() ? SBS_DOWN : SBS_UP); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
299 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
300 |
int cg_ofst; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
301 |
int x = 89; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
302 |
int y = 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
303 |
int xb = 2; ///< offset from left of widget |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
304 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
305 |
uint i = 0; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
306 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
307 |
const CargoSpec *cs = GetCargo(c); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
308 |
if (!cs->IsValid()) continue; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
309 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
310 |
cg_ofst = HasBit(this->cargo_filter, c) ? 2 : 1; |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
311 |
GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
312 |
DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, TC_BLACK); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
313 |
x += 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
314 |
i++; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
315 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
316 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
317 |
x += 6; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
318 |
cg_ofst = this->IsWidgetLowered(SLW_NOCARGOWAITING) ? 2 : 1; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
319 |
DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, TC_BLACK); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
320 |
x += 14; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
321 |
cg_ofst = this->IsWidgetLowered(SLW_CARGOALL) ? 2 : 1; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
322 |
DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
323 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
324 |
cg_ofst = this->IsWidgetLowered(SLW_FACILALL) ? 2 : 1; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
325 |
DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
326 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
327 |
if (this->vscroll.count == 0) { // player has no stations |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
328 |
DrawString(xb, 40, STR_304A_NONE, TC_FROMSTRING); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
329 |
return; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
330 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
331 |
|
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
332 |
int max = min(this->vscroll.pos + this->vscroll.cap, this->stations.Length()); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
333 |
y = 40; // start of the list-widget |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
334 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
335 |
for (int i = this->vscroll.pos; i < max; ++i) { // do until max number of stations of owner |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
336 |
const Station *st = this->stations[i]; |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
337 |
int x; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
338 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
339 |
assert(st->xy != 0); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
340 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
341 |
/* Do not do the complex check HasStationInUse here, it may be even false |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
342 |
* when the order had been removed and the station list hasn't been removed yet */ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
343 |
assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy())); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
344 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
345 |
SetDParam(0, st->index); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
346 |
SetDParam(1, st->facilities); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
347 |
x = DrawString(xb, y, STR_3049_0, TC_FROMSTRING) + 5; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
348 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
349 |
/* show cargo waiting and station ratings */ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
350 |
for (CargoID j = 0; j < NUM_CARGO; j++) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
351 |
if (!st->goods[j].cargo.Empty()) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
352 |
StationsWndShowStationRating(x, y, j, st->goods[j].cargo.Count(), st->goods[j].rating); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
353 |
x += 20; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
354 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
355 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
356 |
y += 10; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
357 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
358 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
359 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
360 |
virtual void OnClick(Point pt, int widget) |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
361 |
{ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
362 |
switch (widget) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
363 |
case SLW_LIST: { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
364 |
uint32 id_v = (pt.y - 41) / 10; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
365 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
366 |
if (id_v >= this->vscroll.cap) return; // click out of bounds |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
367 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
368 |
id_v += this->vscroll.pos; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
369 |
|
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
370 |
if (id_v >= this->stations.Length()) return; // click out of list bound |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
371 |
|
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
372 |
const Station *st = this->stations[id_v]; |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
373 |
/* do not check HasStationInUse - it is slow and may be invalid */ |
10536
6824a85fa05e
(svn r13080) -Fix: warning about unused variable when compiling without asserts
smatz
parents:
10525
diff
changeset
|
374 |
assert(st->owner == (PlayerID)this->window_number || (st->owner == OWNER_NONE && !st->IsBuoy())); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
375 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
376 |
if (_ctrl_pressed) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
377 |
ShowExtraViewPortWindow(st->xy); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
378 |
} else { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
379 |
ScrollMainWindowToTile(st->xy); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
380 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
381 |
break; |
3812
d9b3041ee3d0
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
382 |
} |
d9b3041ee3d0
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
383 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
384 |
case SLW_TRAIN: |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
385 |
case SLW_TRUCK: |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
386 |
case SLW_BUS: |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
387 |
case SLW_AIRPLANE: |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
388 |
case SLW_SHIP: |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
389 |
if (_ctrl_pressed) { |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
390 |
ToggleBit(this->facilities, widget - SLW_TRAIN); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
391 |
this->ToggleWidgetLoweredState(widget); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
392 |
} else { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
393 |
uint i; |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
394 |
FOR_EACH_SET_BIT(i, this->facilities) { |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
395 |
this->RaiseWidget(i + SLW_TRAIN); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
396 |
} |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
397 |
SetBit(this->facilities, widget - SLW_TRAIN); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
398 |
this->LowerWidget(widget); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
399 |
} |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
400 |
this->SetWidgetLoweredState(SLW_FACILALL, this->facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK)); |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
401 |
this->stations.ForceRebuild(); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
402 |
this->SetDirty(); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
403 |
break; |
5271
419c6746fd90
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
404 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
405 |
case SLW_FACILALL: |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
406 |
for (uint i = 0; i < 5; i++) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
407 |
this->LowerWidget(i + SLW_TRAIN); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
408 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
409 |
this->LowerWidget(SLW_FACILALL); |
0 | 410 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
411 |
this->facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK; |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
412 |
this->stations.ForceRebuild(); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
413 |
this->SetDirty(); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
414 |
break; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
415 |
|
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
416 |
case SLW_CARGOALL: { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
417 |
uint i = 0; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
418 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
419 |
if (!GetCargo(c)->IsValid()) continue; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
420 |
this->LowerWidget(i + SLW_CARGOSTART); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
421 |
i++; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
422 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
423 |
this->LowerWidget(SLW_NOCARGOWAITING); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
424 |
this->LowerWidget(SLW_CARGOALL); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
425 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
426 |
this->cargo_filter = _cargo_mask; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
427 |
this->include_empty = true; |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
428 |
this->stations.ForceRebuild(); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
429 |
this->SetDirty(); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
430 |
break; |
0 | 431 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
432 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
433 |
case SLW_SORTBY: // flip sorting method asc/desc |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
434 |
this->stations.ToggleSortOrder(); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
435 |
this->flags4 |= 5 << WF_TIMEOUT_SHL; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
436 |
this->LowerWidget(SLW_SORTBY); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
437 |
this->SetDirty(); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
438 |
break; |
0 | 439 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
440 |
case SLW_SORTDROPBTN: // select sorting criteria dropdown menu |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
441 |
ShowDropDownMenu(this, this->sorter_names, this->stations.SortType(), SLW_SORTDROPBTN, 0, 0); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
442 |
break; |
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
|
443 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
444 |
case SLW_NOCARGOWAITING: |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
445 |
if (_ctrl_pressed) { |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
446 |
this->include_empty = !this->include_empty; |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
447 |
this->ToggleWidgetLoweredState(SLW_NOCARGOWAITING); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
448 |
} else { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
449 |
for (uint i = SLW_CARGOSTART; i < this->widget_count; i++) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
450 |
this->RaiseWidget(i); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
451 |
} |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
452 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
453 |
this->cargo_filter = 0; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
454 |
this->include_empty = true; |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
455 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
456 |
this->LowerWidget(SLW_NOCARGOWAITING); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
457 |
} |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
458 |
this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty); |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
459 |
this->stations.ForceRebuild(); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
460 |
this->SetDirty(); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
461 |
break; |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
462 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
463 |
default: |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
464 |
if (widget >= SLW_CARGOSTART) { // change cargo_filter |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
465 |
/* Determine the selected cargo type */ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
466 |
CargoID c; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
467 |
int i = 0; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
468 |
for (c = 0; c < NUM_CARGO; c++) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
469 |
if (!GetCargo(c)->IsValid()) continue; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
470 |
if (widget - SLW_CARGOSTART == i) break; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
471 |
i++; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
472 |
} |
10411
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10255
diff
changeset
|
473 |
|
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10255
diff
changeset
|
474 |
if (_ctrl_pressed) { |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
475 |
ToggleBit(this->cargo_filter, c); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
476 |
this->ToggleWidgetLoweredState(widget); |
10411
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10255
diff
changeset
|
477 |
} else { |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
478 |
for (uint i = SLW_CARGOSTART; i < this->widget_count; i++) { |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
479 |
this->RaiseWidget(i); |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
480 |
} |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
481 |
this->RaiseWidget(SLW_NOCARGOWAITING); |
6597
e4ce4b1aa3bf
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6586
diff
changeset
|
482 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
483 |
this->cargo_filter = 0; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
484 |
this->include_empty = false; |
6597
e4ce4b1aa3bf
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6586
diff
changeset
|
485 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
486 |
SetBit(this->cargo_filter, c); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
487 |
this->LowerWidget(widget); |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
488 |
} |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
489 |
this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty); |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
490 |
this->stations.ForceRebuild(); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
491 |
this->SetDirty(); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
492 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
493 |
break; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
494 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
495 |
} |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
496 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
497 |
virtual void OnDropdownSelect(int widget, int index) |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
498 |
{ |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
499 |
if (this->stations.SortType() != index) { |
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
500 |
this->stations.SetSortType(index); |
10749
b8ac8a8e27c4
(svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13
parents:
10742
diff
changeset
|
501 |
|
b8ac8a8e27c4
(svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13
parents:
10742
diff
changeset
|
502 |
/* Display the current sort variant */ |
b8ac8a8e27c4
(svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13
parents:
10742
diff
changeset
|
503 |
this->widget[SLW_SORTDROPBTN].data = this->sorter_names[this->stations.SortType()]; |
b8ac8a8e27c4
(svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13
parents:
10742
diff
changeset
|
504 |
|
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
505 |
this->SetDirty(); |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
506 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
507 |
} |
5271
419c6746fd90
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
508 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
509 |
virtual void OnTick() |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
510 |
{ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
511 |
if (_pause_game != 0) return; |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
512 |
if (this->stations.NeedResort()) { |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
513 |
DEBUG(misc, 3, "Periodic rebuild station list player %d", this->window_number); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
514 |
this->SetDirty(); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
515 |
} |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
516 |
} |
0 | 517 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
518 |
virtual void OnTimeout() |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
519 |
{ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
520 |
this->RaiseWidget(SLW_SORTBY); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
521 |
this->SetDirty(); |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
522 |
} |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
523 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
524 |
virtual void OnResize(Point new_size, Point delta) |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
525 |
{ |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
526 |
this->vscroll.cap += delta.y / 10; |
0 | 527 |
} |
10621
3edd349d9c14
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium
parents:
10595
diff
changeset
|
528 |
|
3edd349d9c14
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium
parents:
10595
diff
changeset
|
529 |
virtual void OnInvalidateData(int data) |
3edd349d9c14
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium
parents:
10595
diff
changeset
|
530 |
{ |
10733
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
531 |
if (data == 0) { |
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
532 |
this->stations.ForceRebuild(); |
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
533 |
} else { |
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
534 |
this->stations.ForceResort(); |
f836478e695f
(svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13
parents:
10716
diff
changeset
|
535 |
} |
10621
3edd349d9c14
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium
parents:
10595
diff
changeset
|
536 |
} |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
537 |
}; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
538 |
|
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
539 |
Listing PlayerStationsWindow::last_sorting = {false, 0}; |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
540 |
byte PlayerStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK; |
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
541 |
bool PlayerStationsWindow::include_empty = true; |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
542 |
const uint32 PlayerStationsWindow::cargo_filter_max = UINT32_MAX; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
543 |
uint32 PlayerStationsWindow::cargo_filter = UINT32_MAX; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
544 |
const Station *PlayerStationsWindow::last_station = NULL; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
545 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
546 |
/* Availible station sorting functions */ |
10742 | 547 |
GUIStationList::SortFunction *const PlayerStationsWindow::sorter_funcs[] = { |
10735
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
548 |
&StationNameSorter, |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
549 |
&StationTypeSorter, |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
550 |
&StationWaitingSorter, |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
551 |
&StationRatingMaxSorter |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
552 |
}; |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
553 |
|
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
554 |
/* Names of the sorting functions */ |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
555 |
const StringID PlayerStationsWindow::sorter_names[] = { |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
556 |
STR_SORT_BY_DROPDOWN_NAME, |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
557 |
STR_SORT_BY_FACILITY, |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
558 |
STR_SORT_BY_WAITING, |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
559 |
STR_SORT_BY_RATING_MAX, |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
560 |
INVALID_STRING_ID |
e658a7c8bb89
(svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13
parents:
10733
diff
changeset
|
561 |
}; |
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
562 |
|
0 | 563 |
|
564 |
static const Widget _player_stations_widgets[] = { |
|
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
565 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SLW_CLOSEBOX |
3554
c16eadc2d060
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
566 |
{ 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
|
567 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON}, |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
568 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 345, 37, 161, 0x0, STR_3057_STATION_NAMES_CLICK_ON}, // SLW_LIST |
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_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
|
570 |
{ 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
|
571 |
|
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
572 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 13, 14, 24, STR_TRAIN, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_TRAIN |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
573 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 27, 14, 24, STR_LORRY, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_TRUCK |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
574 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 28, 41, 14, 24, STR_BUS, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_BUS |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
575 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 42, 55, 14, 24, STR_PLANE, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_AIRPLANE |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
576 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 56, 69, 14, 24, STR_SHIP, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_SHIP |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
577 |
{ WWT_PANEL, RESIZE_NONE, 14, 70, 83, 14, 24, 0x0, STR_SELECT_ALL_FACILITIES}, // SLW_FACILALL |
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
|
578 |
|
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
579 |
{ WWT_PANEL, RESIZE_NONE, 14, 83, 88, 14, 24, 0x0, STR_NULL}, // SLW_PAN_BETWEEN |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
580 |
{ WWT_PANEL, RESIZE_NONE, 14, 89, 102, 14, 24, 0x0, STR_NO_WAITING_CARGO}, // SLW_NOCARGOWAITING |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
581 |
{ WWT_PANEL, RESIZE_NONE, 14, 103, 116, 14, 24, 0x0, STR_SELECT_ALL_TYPES}, // SLW_CARGOALL |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
582 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 117, 357, 14, 24, 0x0, STR_NULL}, // SLW_PAN_RIGHT |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
583 |
|
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
584 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 80, 25, 36, STR_SORT_BY, STR_SORT_ORDER_TIP}, // SLW_SORTBY |
8834
ef15cacd6894
(svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents:
8780
diff
changeset
|
585 |
{ WWT_DROPDOWN, RESIZE_NONE, 14, 81, 243, 25, 36, 0x0, STR_SORT_CRITERIA_TIP}, // SLW_SORTDROPBTN |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
586 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 244, 357, 25, 36, 0x0, STR_NULL}, // SLW_PAN_SORT_RIGHT |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
587 |
{ WIDGETS_END}, |
0 | 588 |
}; |
589 |
||
590 |
static const WindowDesc _player_stations_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7554
diff
changeset
|
591 |
WDP_AUTO, WDP_AUTO, 358, 162, 358, 162, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5996
diff
changeset
|
592 |
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
|
593 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 594 |
_player_stations_widgets, |
595 |
}; |
|
596 |
||
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
597 |
/** |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
598 |
* Opens window with list of player's stations |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
599 |
* |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
600 |
* @param player player whose stations' list show |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
601 |
*/ |
2475 | 602 |
void ShowPlayerStations(PlayerID player) |
0 | 603 |
{ |
11161
7d0fac8f14cd
(svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
rubidium
parents:
11157
diff
changeset
|
604 |
if (!IsValidPlayerID(player)) return; |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4938
diff
changeset
|
605 |
|
10511
c625d173480f
(svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium
parents:
10510
diff
changeset
|
606 |
AllocateWindowDescFront<PlayerStationsWindow>(&_player_stations_desc, player); |
0 | 607 |
} |
608 |
||
609 |
static const Widget _station_view_widgets[] = { |
|
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
610 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SVW_CLOSEBOX |
8916
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
611 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 236, 0, 13, STR_300A_0, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
612 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON}, |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
613 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 236, 14, 65, 0x0, STR_NULL}, // SVW_WAITING |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
614 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
615 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 248, 66, 97, 0x0, STR_NULL}, // SVW_ACCEPTLIST / SVW_RATINGLIST |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
616 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 59, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
617 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 60, 120, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, // SVW_RATINGS / SVW_ACCEPTS |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
618 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 121, 180, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, // SVW_RENAME |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
619 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 181, 194, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, // SVW_TRAINS |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
620 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 195, 208, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, // SVW_ROADVEHS |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
621 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 209, 222, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, // SVW_PLANES |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
622 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 223, 236, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, // SVW_SHIPS |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
623 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 237, 248, 98, 109, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
624 |
{ WIDGETS_END}, |
0 | 625 |
}; |
626 |
||
9258
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
627 |
SpriteID GetCargoSprite(CargoID i) |
6690
d037c31fd4cf
(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138
parents:
6676
diff
changeset
|
628 |
{ |
d037c31fd4cf
(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138
parents:
6676
diff
changeset
|
629 |
const CargoSpec *cs = GetCargo(i); |
6691
e8c27a509894
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6690
diff
changeset
|
630 |
SpriteID sprite; |
e8c27a509894
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6690
diff
changeset
|
631 |
|
e8c27a509894
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6690
diff
changeset
|
632 |
if (cs->sprite == 0xFFFF) { |
e8c27a509894
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6690
diff
changeset
|
633 |
/* A value of 0xFFFF indicates we should draw a custom icon */ |
e8c27a509894
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6690
diff
changeset
|
634 |
sprite = GetCustomCargoSprite(cs); |
e8c27a509894
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6690
diff
changeset
|
635 |
} else { |
e8c27a509894
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6690
diff
changeset
|
636 |
sprite = cs->sprite; |
e8c27a509894
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6690
diff
changeset
|
637 |
} |
e8c27a509894
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6690
diff
changeset
|
638 |
|
7153
85b73fcc076b
(svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138
parents:
6916
diff
changeset
|
639 |
if (sprite == 0) sprite = SPR_CARGO_GOODS; |
6690
d037c31fd4cf
(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138
parents:
6676
diff
changeset
|
640 |
|
9258
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
641 |
return sprite; |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
642 |
} |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
643 |
|
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
644 |
/** |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
645 |
* Draws icons of waiting cargo in the StationView window |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
646 |
* |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
647 |
* @param i type of cargo |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
648 |
* @param waiting number of waiting units |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
649 |
* @param x x on-screen coordinate where to start with drawing icons |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
650 |
* @param y y coordinate |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
651 |
*/ |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
652 |
static void DrawCargoIcons(CargoID i, uint waiting, int x, int y, uint width) |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
653 |
{ |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
654 |
uint num = min((waiting + 5) / 10, width / 10); // maximum is width / 10 icons so it won't overflow |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
655 |
if (num == 0) return; |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
656 |
|
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
657 |
SpriteID sprite = GetCargoSprite(i); |
c00ebaa5bf90
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
9246
diff
changeset
|
658 |
|
6690
d037c31fd4cf
(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138
parents:
6676
diff
changeset
|
659 |
do { |
d037c31fd4cf
(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138
parents:
6676
diff
changeset
|
660 |
DrawSprite(sprite, PAL_NONE, x, y); |
d037c31fd4cf
(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138
parents:
6676
diff
changeset
|
661 |
x += 10; |
d037c31fd4cf
(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138
parents:
6676
diff
changeset
|
662 |
} while (--num); |
d037c31fd4cf
(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138
parents:
6676
diff
changeset
|
663 |
} |
d037c31fd4cf
(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138
parents:
6676
diff
changeset
|
664 |
|
8916
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
665 |
struct CargoData { |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
666 |
CargoID cargo; |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
667 |
StationID source; |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
668 |
uint count; |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
669 |
|
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
670 |
CargoData(CargoID cargo, StationID source, uint count) : |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
671 |
cargo(cargo), |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
672 |
source(source), |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
673 |
count(count) |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
674 |
{ } |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
675 |
}; |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
676 |
|
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
677 |
typedef std::list<CargoData> CargoDataList; |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
678 |
|
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
679 |
/** |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
680 |
* The StationView window |
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
681 |
*/ |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
682 |
struct StationViewWindow : public Window { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
683 |
uint32 cargo; ///< Bitmask of cargo types to expand |
10752
332994dbea4e
(svn r13302) -Fix (r13301): GCC doesn't necessarily like what MSVC likes...
rubidium
parents:
10751
diff
changeset
|
684 |
uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type |
9246
14265864e804
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
9215
diff
changeset
|
685 |
|
10525
da5bc725cda4
(svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
rubidium
parents:
10511
diff
changeset
|
686 |
StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
687 |
{ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
688 |
PlayerID owner = GetStation(window_number)->owner; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
689 |
if (owner != OWNER_NONE) this->caption_color = owner; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
690 |
this->vscroll.cap = 5; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
691 |
this->resize.step_height = 10; |
9246
14265864e804
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
9215
diff
changeset
|
692 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
693 |
this->FindWindowPlacementAndResize(desc); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
694 |
} |
9246
14265864e804
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
9215
diff
changeset
|
695 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
696 |
~StationViewWindow() |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
697 |
{ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
698 |
WindowNumber wno = |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
699 |
(this->window_number << 16) | VLW_STATION_LIST | GetStation(this->window_number)->owner; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
700 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
701 |
DeleteWindowById(WC_TRAINS_LIST, wno); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
702 |
DeleteWindowById(WC_ROADVEH_LIST, wno); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
703 |
DeleteWindowById(WC_SHIPS_LIST, wno); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
704 |
DeleteWindowById(WC_AIRCRAFT_LIST, wno); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
705 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
706 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
707 |
virtual void OnPaint() |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
708 |
{ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
709 |
StationID station_id = this->window_number; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
710 |
const Station *st = GetStation(station_id); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
711 |
CargoDataList cargolist; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
712 |
uint32 transfers = 0; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
713 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
714 |
/* count types of cargos waiting in station */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
715 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
716 |
if (st->goods[i].cargo.Empty()) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
717 |
this->cargo_rows[i] = 0; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
718 |
} else { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
719 |
/* Add an entry for total amount of cargo of this type waiting. */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
720 |
cargolist.push_back(CargoData(i, INVALID_STATION, st->goods[i].cargo.Count())); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
721 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
722 |
/* Set the row for this cargo entry for the expand/hide button */ |
10752
332994dbea4e
(svn r13302) -Fix (r13301): GCC doesn't necessarily like what MSVC likes...
rubidium
parents:
10751
diff
changeset
|
723 |
this->cargo_rows[i] = (uint16)cargolist.size(); |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
724 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
725 |
/* Add an entry for each distinct cargo source. */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
726 |
const CargoList::List *packets = st->goods[i].cargo.Packets(); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
727 |
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
728 |
const CargoPacket *cp = *it; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
729 |
if (cp->source != station_id) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
730 |
bool added = false; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
731 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
732 |
/* Enable the expand/hide button for this cargo type */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
733 |
SetBit(transfers, i); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
734 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
735 |
/* Don't add cargo lines if not expanded */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
736 |
if (!HasBit(this->cargo, i)) break; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
737 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
738 |
/* Check if we already have this source in the list */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
739 |
for (CargoDataList::iterator jt = cargolist.begin(); jt != cargolist.end(); jt++) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
740 |
CargoData *cd = &(*jt); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
741 |
if (cd->cargo == i && cd->source == cp->source) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
742 |
cd->count += cp->count; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
743 |
added = true; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
744 |
break; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
745 |
} |
8916
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
746 |
} |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
747 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
748 |
if (!added) cargolist.push_back(CargoData(i, cp->source, cp->count)); |
8916
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
749 |
} |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
750 |
} |
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
751 |
} |
0 | 752 |
} |
10751
ebd94f2d6385
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents:
10749
diff
changeset
|
753 |
SetVScrollCount(this, (int)cargolist.size() + 1); // update scrollbar |
10224
4f7e3408936b
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
10083
diff
changeset
|
754 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
755 |
/* disable some buttons */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
756 |
this->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_player); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
757 |
this->SetWidgetDisabledState(SVW_TRAINS, !(st->facilities & FACIL_TRAIN)); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
758 |
this->SetWidgetDisabledState(SVW_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP)); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
759 |
this->SetWidgetDisabledState(SVW_PLANES, !(st->facilities & FACIL_AIRPORT)); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
760 |
this->SetWidgetDisabledState(SVW_SHIPS, !(st->facilities & FACIL_DOCK)); |
0 | 761 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
762 |
SetDParam(0, st->index); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
763 |
SetDParam(1, st->facilities); |
10595
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10536
diff
changeset
|
764 |
this->DrawWidgets(); |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
765 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
766 |
int x = 2; ///< coordinates used for printing waiting/accepted/rating of cargo |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
767 |
int y = 15; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
768 |
int pos = this->vscroll.pos; ///< = this->vscroll.pos |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
769 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
770 |
uint width = this->widget[SVW_WAITING].right - this->widget[SVW_WAITING].left - 4; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
771 |
int maxrows = this->vscroll.cap; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
772 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
773 |
StringID str; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
774 |
|
8916
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
775 |
if (--pos < 0) { |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
776 |
str = STR_00D0_NOTHING; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
777 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
778 |
if (!st->goods[i].cargo.Empty()) str = STR_EMPTY; |
0 | 779 |
} |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
780 |
SetDParam(0, str); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
781 |
DrawString(x, y, STR_0008_WAITING, TC_FROMSTRING); |
8916
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
782 |
y += 10; |
0 | 783 |
} |
784 |
||
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
785 |
for (CargoDataList::const_iterator it = cargolist.begin(); it != cargolist.end() && pos > -maxrows; ++it) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
786 |
if (--pos < 0) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
787 |
const CargoData *cd = &(*it); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
788 |
if (cd->source == INVALID_STATION) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
789 |
/* Heading */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
790 |
DrawCargoIcons(cd->cargo, cd->count, x, y, width); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
791 |
SetDParam(0, cd->cargo); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
792 |
SetDParam(1, cd->count); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
793 |
if (HasBit(transfers, cd->cargo)) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
794 |
/* This cargo has transfers waiting so show the expand or shrink 'button' */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
795 |
const char *sym = HasBit(this->cargo, cd->cargo) ? "-" : "+"; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
796 |
DrawStringRightAligned(x + width - 8, y, STR_0009, TC_FROMSTRING); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
797 |
DoDrawString(sym, x + width - 6, y, TC_YELLOW); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
798 |
} else { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
799 |
DrawStringRightAligned(x + width, y, STR_0009, TC_FROMSTRING); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
800 |
} |
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
801 |
} else { |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
802 |
SetDParam(0, cd->cargo); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
803 |
SetDParam(1, cd->count); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
804 |
SetDParam(2, cd->source); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
805 |
DrawStringRightAlignedTruncated(x + width, y, STR_EN_ROUTE_FROM, TC_FROMSTRING, width); |
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
806 |
} |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
807 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
808 |
y += 10; |
0 | 809 |
} |
810 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
811 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
812 |
if (this->widget[SVW_ACCEPTS].data == STR_3032_RATINGS) { // small window with list of accepted cargo |
11157
a0173588b15e
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium
parents:
11060
diff
changeset
|
813 |
char string[512]; |
a0173588b15e
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium
parents:
11060
diff
changeset
|
814 |
char *b = string; |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
815 |
bool first = true; |
6623
1115fe0767a9
(svn r9127) -Codechange: Check if a cargo is valid before displaying it in a station's cargo rating list. (And duff up the block a little)
peter1138
parents:
6611
diff
changeset
|
816 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
817 |
b = InlineString(b, STR_000C_ACCEPTS); |
6623
1115fe0767a9
(svn r9127) -Codechange: Check if a cargo is valid before displaying it in a station's cargo rating list. (And duff up the block a little)
peter1138
parents:
6611
diff
changeset
|
818 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
819 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
11157
a0173588b15e
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium
parents:
11060
diff
changeset
|
820 |
if (b >= lastof(string) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode() |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
821 |
if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE)) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
822 |
if (first) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
823 |
first = false; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
824 |
} else { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
825 |
/* Add a comma if this is not the first item */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
826 |
*b++ = ','; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
827 |
*b++ = ' '; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
828 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
829 |
b = InlineString(b, GetCargo(i)->name); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
830 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
831 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
832 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
833 |
/* If first is still true then no cargo is accepted */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
834 |
if (first) b = InlineString(b, STR_00D0_NOTHING); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
835 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
836 |
*b = '\0'; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
837 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
838 |
/* Make sure we detect any buffer overflow */ |
11157
a0173588b15e
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium
parents:
11060
diff
changeset
|
839 |
assert(b < endof(string)); |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
840 |
|
11157
a0173588b15e
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium
parents:
11060
diff
changeset
|
841 |
SetDParamStr(0, string); |
a0173588b15e
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium
parents:
11060
diff
changeset
|
842 |
DrawStringMultiLine(2, this->widget[SVW_ACCEPTLIST].top + 1, STR_JUST_RAW_STRING, this->widget[SVW_ACCEPTLIST].right - this->widget[SVW_ACCEPTLIST].left); |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
843 |
} else { // extended window with list of cargo ratings |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
844 |
y = this->widget[SVW_RATINGLIST].top + 1; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
845 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
846 |
DrawString(2, y, STR_3034_LOCAL_RATING_OF_TRANSPORT, TC_FROMSTRING); |
6623
1115fe0767a9
(svn r9127) -Codechange: Check if a cargo is valid before displaying it in a station's cargo rating list. (And duff up the block a little)
peter1138
parents:
6611
diff
changeset
|
847 |
y += 10; |
0 | 848 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
849 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
850 |
const CargoSpec *cs = GetCargo(i); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
851 |
if (!cs->IsValid()) continue; |
9246
14265864e804
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
9215
diff
changeset
|
852 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
853 |
const GoodsEntry *ge = &st->goods[i]; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
854 |
if (!HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP)) continue; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
855 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
856 |
SetDParam(0, cs->name); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
857 |
SetDParam(2, ge->rating * 101 >> 8); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
858 |
SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5)); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
859 |
DrawString(8, y, STR_303D, TC_FROMSTRING); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
860 |
y += 10; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
861 |
} |
9246
14265864e804
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
9215
diff
changeset
|
862 |
} |
14265864e804
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
9215
diff
changeset
|
863 |
} |
14265864e804
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
9215
diff
changeset
|
864 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
865 |
void HandleCargoWaitingClick(int row) |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
866 |
{ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
867 |
if (row == 0) return; |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
868 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
869 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
870 |
if (this->cargo_rows[c] == row) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
871 |
ToggleBit(this->cargo, c); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
872 |
this->InvalidateWidget(SVW_WAITING); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
873 |
break; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
874 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
875 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
876 |
} |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
877 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
878 |
virtual void OnClick(Point pt, int widget) |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
879 |
{ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
880 |
switch (widget) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
881 |
case SVW_WAITING: |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
882 |
this->HandleCargoWaitingClick((pt.y - this->widget[SVW_WAITING].top) / 10 + this->vscroll.pos); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
883 |
break; |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
884 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
885 |
case SVW_LOCATION: |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
886 |
if (_ctrl_pressed) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
887 |
ShowExtraViewPortWindow(GetStation(this->window_number)->xy); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
888 |
} else { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
889 |
ScrollMainWindowToTile(GetStation(this->window_number)->xy); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
890 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
891 |
break; |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
892 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
893 |
case SVW_RATINGS: |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
894 |
this->SetDirty(); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
895 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
896 |
if (this->widget[SVW_RATINGS].data == STR_3032_RATINGS) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
897 |
/* Switch to ratings view */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
898 |
this->widget[SVW_RATINGS].data = STR_3033_ACCEPTS; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
899 |
this->widget[SVW_RATINGS].tooltips = STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
900 |
ResizeWindowForWidget(this, SVW_ACCEPTLIST, 0, 100); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
901 |
} else { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
902 |
/* Switch to accepts view */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
903 |
this->widget[SVW_RATINGS].data = STR_3032_RATINGS; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
904 |
this->widget[SVW_RATINGS].tooltips = STR_3054_SHOW_STATION_RATINGS; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
905 |
ResizeWindowForWidget(this, SVW_ACCEPTLIST, 0, -100); |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
906 |
} |
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
907 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
908 |
this->SetDirty(); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
909 |
break; |
0 | 910 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
911 |
case SVW_RENAME: |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
912 |
SetDParam(0, this->window_number); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
913 |
ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, this, CS_ALPHANUMERAL); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
914 |
break; |
6528
b705912233fa
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6448
diff
changeset
|
915 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
916 |
case SVW_TRAINS: { // Show a list of scheduled trains to this station |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
917 |
const Station *st = GetStation(this->window_number); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
918 |
ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)this->window_number); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
919 |
break; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
920 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
921 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
922 |
case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
923 |
const Station *st = GetStation(this->window_number); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
924 |
ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)this->window_number); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
925 |
break; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
926 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
927 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
928 |
case SVW_PLANES: { // Show a list of scheduled aircraft to this station |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
929 |
const Station *st = GetStation(this->window_number); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
930 |
/* Since oilrigs have no owners, show the scheduled aircraft of current player */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
931 |
PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
932 |
ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)this->window_number); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
933 |
break; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
934 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
935 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
936 |
case SVW_SHIPS: { // Show a list of scheduled ships to this station |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
937 |
const Station *st = GetStation(this->window_number); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
938 |
/* Since oilrigs/bouys have no owners, show the scheduled ships of current player */ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
939 |
PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
940 |
ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
941 |
break; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
942 |
} |
588 | 943 |
} |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
944 |
} |
8916
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
945 |
|
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
946 |
virtual void OnQueryTextFinished(char *str) |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
947 |
{ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
948 |
if (!StrEmpty(str)) { |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
949 |
_cmd_text = str; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
950 |
DoCommandP(0, this->window_number, 0, NULL, |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
951 |
CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION)); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
952 |
} |
0 | 953 |
} |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
954 |
|
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
955 |
virtual void OnResize(Point new_size, Point delta) |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
956 |
{ |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
957 |
if (delta.x != 0) ResizeButtons(this, SVW_LOCATION, SVW_RENAME); |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
958 |
this->vscroll.cap += delta.y / (int)this->resize.step_height; |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
959 |
} |
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
960 |
}; |
0 | 961 |
|
962 |
||
963 |
static const WindowDesc _station_view_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7554
diff
changeset
|
964 |
WDP_AUTO, WDP_AUTO, 249, 110, 249, 110, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5996
diff
changeset
|
965 |
WC_STATION_VIEW, WC_NONE, |
8916
383cb2ffdb2f
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8845
diff
changeset
|
966 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 967 |
_station_view_widgets, |
968 |
}; |
|
969 |
||
8512
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
970 |
/** |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
971 |
* Opens StationViewWindow for given station |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
972 |
* |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
973 |
* @param station station which window should be opened |
e77c8fb7c0ed
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8501
diff
changeset
|
974 |
*/ |
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
|
975 |
void ShowStationViewWindow(StationID station) |
0 | 976 |
{ |
10505
4dc656969d0d
(svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium
parents:
10484
diff
changeset
|
977 |
AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station); |
0 | 978 |
} |