00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef STATION_GUI_H
00013 #define STATION_GUI_H
00014
00015 #include "command_type.h"
00016 #include "station_type.h"
00017 #include "tilearea_type.h"
00018 #include "window_type.h"
00019 #include "cargo_type.h"
00020 #include <set>
00021
00023 enum StationViewWidgets {
00024 SVW_CAPTION = 0,
00025 SVW_SORT_ORDER = 1,
00026 SVW_SORT_BY = 2,
00027 SVW_GROUP = 3,
00028 SVW_GROUP_BY = 4,
00029 SVW_WAITING = 5,
00030 SVW_SCROLLBAR = 6,
00031 SVW_ACCEPTLIST = 7,
00032 SVW_RATINGLIST = 7,
00033 SVW_LOCATION = 8,
00034 SVW_RATINGS = 9,
00035 SVW_ACCEPTS = 9,
00036 SVW_RENAME = 10,
00037 SVW_TRAINS = 11,
00038 SVW_ROADVEHS,
00039 SVW_SHIPS,
00040 SVW_PLANES,
00041 SVW_DEPARTURES,
00042 };
00043
00045 enum StationCoverageType {
00046 SCT_PASSENGERS_ONLY,
00047 SCT_NON_PASSENGERS_ONLY,
00048 SCT_ALL,
00049 };
00050
00051 int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies);
00052 void CheckRedrawStationCoverage(const Window *w);
00053
00054 void ShowSelectStationIfNeeded(CommandContainer cmd, TileArea ta);
00055 void ShowSelectWaypointIfNeeded(CommandContainer cmd, TileArea ta);
00056
00057 enum SortOrder {
00058 SO_DESCENDING,
00059 SO_ASCENDING
00060 };
00061
00062 class CargoDataEntry;
00063
00064 enum CargoSortType {
00065 ST_AS_GROUPING,
00066 ST_COUNT,
00067 ST_STATION_STRING,
00068 ST_STATION_ID,
00069 ST_CARGO_ID,
00070 };
00071
00072 class CargoSorter {
00073 public:
00074 CargoSorter(CargoSortType t = ST_STATION_ID, SortOrder o = SO_ASCENDING) : type(t), order(o) {}
00075 CargoSortType GetSortType() {return this->type;}
00076 bool operator()(const CargoDataEntry *cd1, const CargoDataEntry *cd2) const;
00077
00078 private:
00079 CargoSortType type;
00080 SortOrder order;
00081
00082 template<class ID>
00083 bool SortId(ID st1, ID st2) const;
00084 bool SortCount(const CargoDataEntry *cd1, const CargoDataEntry *cd2) const;
00085 bool SortStation (StationID st1, StationID st2) const;
00086 };
00087
00088 typedef std::set<CargoDataEntry *, CargoSorter> CargoDataSet;
00089
00095 class CargoDataEntry {
00096 public:
00097 CargoDataEntry();
00098 ~CargoDataEntry();
00099
00105 CargoDataEntry *InsertOrRetrieve(StationID station) {return this->InsertOrRetrieve<StationID>(station);}
00106
00112 CargoDataEntry *InsertOrRetrieve(CargoID cargo) {return this->InsertOrRetrieve<CargoID>(cargo);}
00113
00114 void Update(uint count);
00115
00120 void Remove(StationID station) {CargoDataEntry t(station); this->Remove(&t);}
00121
00126 void Remove(CargoID cargo) {CargoDataEntry t(cargo); this->Remove(&t);}
00127
00133 CargoDataEntry *Retrieve(StationID station) const {CargoDataEntry t(station); return this->Retrieve(this->children->find(&t));}
00134
00140 CargoDataEntry *Retrieve(CargoID cargo) const {CargoDataEntry t(cargo);return this->Retrieve(this->children->find(&t));}
00141
00142 void Resort(CargoSortType type, SortOrder order);
00143
00147 StationID GetStation() const {return this->station;}
00148
00152 CargoID GetCargo() const {return this->cargo;}
00153
00157 uint GetCount() const {return this->count;}
00158
00162 CargoDataEntry *GetParent() const {return this->parent;}
00163
00167 uint GetNumChildren() const {return this->num_children;}
00168
00172 CargoDataSet::iterator Begin() const {return this->children->begin();}
00173
00177 CargoDataSet::iterator End() const {return this->children->end();}
00178
00179 void Clear();
00180 private:
00181
00182 CargoDataEntry(StationID st, uint c, CargoDataEntry *p);
00183 CargoDataEntry(CargoID car, uint c, CargoDataEntry *p);
00184 CargoDataEntry(StationID st);
00185 CargoDataEntry(CargoID car);
00186
00187 CargoDataEntry *Retrieve(CargoDataSet::iterator i) const;
00188
00189 template<class ID>
00190 CargoDataEntry *InsertOrRetrieve(ID s);
00191
00192 void Remove(CargoDataEntry *comp);
00193 void IncrementSize();
00194
00195 CargoDataEntry *parent;
00196 const union {
00197 StationID station;
00198 CargoID cargo;
00199 };
00200 uint num_children;
00201 uint count;
00202 CargoDataSet *children;
00203 };
00204
00205 #endif