(svn r28004) -Update from Eints:
[openttd.git] / src / newgrf_airporttiles.h
blobdc0464203709e605824af7b8144c604a5f45655b
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file newgrf_airporttiles.h NewGRF handling of airport tiles. */
12 #ifndef NEWGRF_AIRPORTTILES_H
13 #define NEWGRF_AIRPORTTILES_H
15 #include "airport.h"
16 #include "station_map.h"
17 #include "newgrf_animation_type.h"
18 #include "newgrf_commons.h"
19 #include "newgrf_spritegroup.h"
20 #include "station_base.h"
22 /** Scope resolver for handling the tiles of an airport. */
23 struct AirportTileScopeResolver : public ScopeResolver {
24 struct Station *st; ///< %Station of the airport for which the callback is run, or \c NULL for build gui.
25 byte airport_id; ///< Type of airport for which the callback is run.
26 TileIndex tile; ///< Tile for the callback, only valid for airporttile callbacks.
28 /**
29 * Constructor of the scope resolver specific for airport tiles.
30 * @param ats Specification of the airport tiles.
31 * @param tile %Tile for the callback, only valid for airporttile callbacks.
32 * @param st Station of the airport for which the callback is run, or \c NULL for build gui.
34 AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st)
35 : ScopeResolver(ro), st(st), tile(tile)
37 assert(st != NULL);
38 this->airport_id = st->airport.type;
41 /* virtual */ uint32 GetRandomBits() const;
42 /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
45 /** Resolver for tiles of an airport. */
46 struct AirportTileResolverObject : public ResolverObject {
47 AirportTileScopeResolver tiles_scope; ///< Scope resolver for the tiles.
49 AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st,
50 CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
52 /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
54 switch (scope) {
55 case VSG_SCOPE_SELF: return &tiles_scope;
56 default: return ResolverObject::GetScope(scope, relative);
61 /**
62 * Defines the data structure of each individual tile of an airport.
64 struct AirportTileSpec {
65 AnimationInfo animation; ///< Information about the animation.
66 StringID name; ///< Tile Subname string, land information on this tile will give you "AirportName (TileSubname)"
67 uint8 callback_mask; ///< Bitmask telling which grf callback is set
68 uint8 animation_special_flags; ///< Extra flags to influence the animation
69 bool enabled; ///< entity still available (by default true). newgrf can disable it, though
70 GRFFileProps grf_prop; ///< properties related the the grf file
72 static const AirportTileSpec *Get(StationGfx gfx);
73 static const AirportTileSpec *GetByTile(TileIndex tile);
75 static void ResetAirportTiles();
77 private:
78 static AirportTileSpec tiles[NUM_AIRPORTTILES];
80 friend void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts);
83 StationGfx GetTranslatedAirportTileID(StationGfx gfx);
84 void AnimateAirportTile(TileIndex tile);
85 void AirportTileAnimationTrigger(Station *st, TileIndex tile, AirpAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
86 void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
87 bool DrawNewAirportTile(TileInfo *ti, Station *st, StationGfx gfx, const AirportTileSpec *airts);
89 #endif /* NEWGRF_AIRPORTTILES_H */