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 };
00042
00044 enum StationCoverageType {
00045 SCT_PASSENGERS_ONLY,
00046 SCT_NON_PASSENGERS_ONLY,
00047 SCT_ALL,
00048 };
00049
00050 int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies);
00051 void CheckRedrawStationCoverage(const Window *w);
00052
00053 void ShowSelectStationIfNeeded(CommandContainer cmd, TileArea ta);
00054 void ShowSelectWaypointIfNeeded(CommandContainer cmd, TileArea ta);
00055
00056 enum SortOrder {
00057 SO_DESCENDING,
00058 SO_ASCENDING
00059 };
00060
00061 class CargoDataEntry;
00062
00063 enum CargoSortType {
00064 ST_AS_GROUPING,
00065 ST_COUNT,
00066 ST_STATION_STRING,
00067 ST_STATION_ID,
00068 ST_CARGO_ID,
00069 };
00070
00071 class CargoSorter {
00072 public:
00073 CargoSorter(CargoSortType t = ST_STATION_ID, SortOrder o = SO_ASCENDING) : type(t), order(o) {}
00074 CargoSortType GetSortType() {return this->type;}
00075 bool operator()(const CargoDataEntry *cd1, const CargoDataEntry *cd2) const;
00076
00077 private:
00078 CargoSortType type;
00079 SortOrder order;
00080
00081 template<class ID>
00082 bool SortId(ID st1, ID st2) const;
00083 bool SortCount(const CargoDataEntry *cd1, const CargoDataEntry *cd2) const;
00084 bool SortStation (StationID st1, StationID st2) const;
00085 };
00086
00087 typedef std::set<CargoDataEntry *, CargoSorter> CargoDataSet;
00088
00094 class CargoDataEntry {
00095 public:
00096 CargoDataEntry();
00097 ~CargoDataEntry();
00098
00104 CargoDataEntry *InsertOrRetrieve(StationID station) {return this->InsertOrRetrieve<StationID>(station);}
00105
00111 CargoDataEntry *InsertOrRetrieve(CargoID cargo) {return this->InsertOrRetrieve<CargoID>(cargo);}
00112
00113 void Update(uint count);
00114
00119 void Remove(StationID station) {CargoDataEntry t(station); this->Remove(&t);}
00120
00125 void Remove(CargoID cargo) {CargoDataEntry t(cargo); this->Remove(&t);}
00126
00132 CargoDataEntry *Retrieve(StationID station) const {CargoDataEntry t(station); return this->Retrieve(this->children->find(&t));}
00133
00139 CargoDataEntry *Retrieve(CargoID cargo) const {CargoDataEntry t(cargo);return this->Retrieve(this->children->find(&t));}
00140
00141 void Resort(CargoSortType type, SortOrder order);
00142
00146 StationID GetStation() const {return this->station;}
00147
00151 CargoID GetCargo() const {return this->cargo;}
00152
00156 uint GetCount() const {return this->count;}
00157
00161 CargoDataEntry *GetParent() const {return this->parent;}
00162
00166 uint GetNumChildren() const {return this->num_children;}
00167
00171 CargoDataSet::iterator Begin() const {return this->children->begin();}
00172
00176 CargoDataSet::iterator End() const {return this->children->end();}
00177
00178 void Clear();
00179 private:
00180
00181 CargoDataEntry(StationID st, uint c, CargoDataEntry *p);
00182 CargoDataEntry(CargoID car, uint c, CargoDataEntry *p);
00183 CargoDataEntry(StationID st);
00184 CargoDataEntry(CargoID car);
00185
00186 CargoDataEntry *Retrieve(CargoDataSet::iterator i) const;
00187
00188 template<class ID>
00189 CargoDataEntry *InsertOrRetrieve(ID s);
00190
00191 void Remove(CargoDataEntry *comp);
00192 void IncrementSize();
00193
00194 CargoDataEntry *parent;
00195 const union {
00196 StationID station;
00197 CargoID cargo;
00198 };
00199 uint num_children;
00200 uint count;
00201 CargoDataSet *children;
00202 };
00203
00204 #endif