Update: Translations from eints
[openttd-github.git] / src / newgrf_airporttiles.h
blob34b36691286bf688e86ba2595970fb5a65003ed4
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file newgrf_airporttiles.h NewGRF handling of airport tiles. */
10 #ifndef NEWGRF_AIRPORTTILES_H
11 #define NEWGRF_AIRPORTTILES_H
13 #include "airport.h"
14 #include "station_map.h"
15 #include "newgrf_animation_type.h"
16 #include "newgrf_commons.h"
17 #include "newgrf_spritegroup.h"
18 #include "station_base.h"
20 /** Scope resolver for handling the tiles of an airport. */
21 struct AirportTileScopeResolver : public ScopeResolver {
22 struct Station *st; ///< %Station of the airport for which the callback is run, or \c nullptr for build gui.
23 uint8_t airport_id; ///< Type of airport for which the callback is run.
24 TileIndex tile; ///< Tile for the callback, only valid for airporttile callbacks.
25 const AirportTileSpec *ats;
27 /**
28 * Constructor of the scope resolver specific for airport tiles.
29 * @param ats Specification of the airport tiles.
30 * @param tile %Tile for the callback, only valid for airporttile callbacks.
31 * @param st Station of the airport for which the callback is run, or \c nullptr for build gui.
33 AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st)
34 : ScopeResolver(ro), st(st), tile(tile), ats(ats)
36 assert(st != nullptr);
37 this->airport_id = st->airport.type;
40 uint32_t GetRandomBits() const override;
41 uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override;
44 /** Resolver for tiles of an airport. */
45 struct AirportTileResolverObject : public ResolverObject {
46 AirportTileScopeResolver tiles_scope; ///< Scope resolver for the tiles.
47 AirportScopeResolver airport_scope; ///< Scope resolver for the airport owning the tile.
49 AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st,
50 CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0);
52 ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, uint8_t relative = 0) override
54 switch (scope) {
55 case VSG_SCOPE_SELF: return &tiles_scope;
56 case VSG_SCOPE_PARENT: return &airport_scope;
57 default: return ResolverObject::GetScope(scope, relative);
61 GrfSpecFeature GetFeature() const override;
62 uint32_t GetDebugID() const override;
65 /**
66 * Defines the data structure of each individual tile of an airport.
68 struct AirportTileSpec {
69 AnimationInfo animation; ///< Information about the animation.
70 StringID name; ///< Tile Subname string, land information on this tile will give you "AirportName (TileSubname)"
71 uint8_t callback_mask; ///< Bitmask telling which grf callback is set
72 uint8_t animation_special_flags; ///< Extra flags to influence the animation
73 bool enabled; ///< entity still available (by default true). newgrf can disable it, though
74 GRFFileProps grf_prop; ///< properties related the the grf file
76 static const AirportTileSpec *Get(StationGfx gfx);
77 static const AirportTileSpec *GetByTile(TileIndex tile);
79 static void ResetAirportTiles();
81 private:
82 static AirportTileSpec tiles[NUM_AIRPORTTILES];
84 friend void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts);
87 void AnimateAirportTile(TileIndex tile);
88 void AirportTileAnimationTrigger(Station *st, TileIndex tile, AirpAnimationTrigger trigger, CargoID cargo_type = INVALID_CARGO);
89 void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID cargo_type = INVALID_CARGO);
90 bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts);
92 #endif /* NEWGRF_AIRPORTTILES_H */