Go to the documentation of this file.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
00022
00024 enum StationCoverageType {
00025 SCT_PASSENGERS_ONLY,
00026 SCT_NON_PASSENGERS_ONLY,
00027 SCT_ALL,
00028 };
00029
00030 int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies);
00031 void CheckRedrawStationCoverage(const Window *w);
00032
00033 void ShowSelectStationIfNeeded(CommandContainer cmd, TileArea ta);
00034 void ShowSelectWaypointIfNeeded(CommandContainer cmd, TileArea ta);
00035
00036 enum SortOrder {
00037 SO_DESCENDING,
00038 SO_ASCENDING
00039 };
00040
00041 class CargoDataEntry;
00042
00043 enum CargoSortType {
00044 ST_AS_GROUPING,
00045 ST_COUNT,
00046 ST_STATION_STRING,
00047 ST_STATION_ID,
00048 ST_CARGO_ID,
00049 };
00050
00051 class CargoSorter {
00052 public:
00053 CargoSorter(CargoSortType t = ST_STATION_ID, SortOrder o = SO_ASCENDING) : type(t), order(o) {}
00054 CargoSortType GetSortType() {return this->type;}
00055 bool operator()(const CargoDataEntry *cd1, const CargoDataEntry *cd2) const;
00056
00057 private:
00058 CargoSortType type;
00059 SortOrder order;
00060
00061 template<class ID>
00062 bool SortId(ID st1, ID st2) const;
00063 bool SortCount(const CargoDataEntry *cd1, const CargoDataEntry *cd2) const;
00064 bool SortStation (StationID st1, StationID st2) const;
00065 };
00066
00067 typedef std::set<CargoDataEntry *, CargoSorter> CargoDataSet;
00068
00074 class CargoDataEntry {
00075 public:
00076 CargoDataEntry();
00077 ~CargoDataEntry();
00078
00084 CargoDataEntry *InsertOrRetrieve(StationID station) {return this->InsertOrRetrieve<StationID>(station);}
00085
00091 CargoDataEntry *InsertOrRetrieve(CargoID cargo) {return this->InsertOrRetrieve<CargoID>(cargo);}
00092
00093 void Update(uint count);
00094
00099 void Remove(StationID station) {CargoDataEntry t(station); this->Remove(&t);}
00100
00105 void Remove(CargoID cargo) {CargoDataEntry t(cargo); this->Remove(&t);}
00106
00112 CargoDataEntry *Retrieve(StationID station) const {CargoDataEntry t(station); return this->Retrieve(this->children->find(&t));}
00113
00119 CargoDataEntry *Retrieve(CargoID cargo) const {CargoDataEntry t(cargo);return this->Retrieve(this->children->find(&t));}
00120
00121 void Resort(CargoSortType type, SortOrder order);
00122
00126 StationID GetStation() const {return this->station;}
00127
00131 CargoID GetCargo() const {return this->cargo;}
00132
00136 uint GetCount() const {return this->count;}
00137
00141 CargoDataEntry *GetParent() const {return this->parent;}
00142
00146 uint GetNumChildren() const {return this->num_children;}
00147
00151 CargoDataSet::iterator Begin() const {return this->children->begin();}
00152
00156 CargoDataSet::iterator End() const {return this->children->end();}
00157
00158 void Clear();
00159 private:
00160
00161 CargoDataEntry(StationID st, uint c, CargoDataEntry *p);
00162 CargoDataEntry(CargoID car, uint c, CargoDataEntry *p);
00163 CargoDataEntry(StationID st);
00164 CargoDataEntry(CargoID car);
00165
00166 CargoDataEntry *Retrieve(CargoDataSet::iterator i) const;
00167
00168 template<class ID>
00169 CargoDataEntry *InsertOrRetrieve(ID s);
00170
00171 void Remove(CargoDataEntry *comp);
00172 void IncrementSize();
00173
00174 CargoDataEntry *parent;
00175 const union {
00176 StationID station;
00177 CargoID cargo;
00178 };
00179 uint num_children;
00180 uint count;
00181 CargoDataSet *children;
00182 };
00183
00184 #endif