OpenTTD

newgrf_airporttiles.h
Go to the documentation of this file.
1 /* $Id: newgrf_airporttiles.h 27984 2018-03-11 13:19:41Z frosch $ */
2
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 */
9
12 #ifndef NEWGRF_AIRPORTTILES_H
13 #define NEWGRF_AIRPORTTILES_H
14
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"
21
23 struct AirportTileScopeResolver : public ScopeResolver {
24 struct Station *st;
25 byte airport_id;
26 TileIndex tile;
27
34 AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st)
35 : ScopeResolver(ro), st(st), tile(tile)
36 {
37 assert(st != NULL);
38 this->airport_id = st->airport.type;
39 }
40
41 /* virtual */ uint32 GetRandomBits() const;
42 /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
43 };
44
46 struct AirportTileResolverObject : public ResolverObject {
47 AirportTileScopeResolver tiles_scope;
48
49 AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st,
50 CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
51
52 /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
53 {
54 switch (scope) {
55 case VSG_SCOPE_SELF: return &tiles_scope;
56 default: return ResolverObject::GetScope(scope, relative);
57 }
58 }
59 };
60
64 struct AirportTileSpec {
65 AnimationInfo animation;
66 StringID name;
67 uint8 callback_mask;
68 uint8 animation_special_flags;
69 bool enabled;
70 GRFFileProps grf_prop;
71
72 static const AirportTileSpec *Get(StationGfx gfx);
73 static const AirportTileSpec *GetByTile(TileIndex tile);
74
75 static void ResetAirportTiles();
76
77 private:
78 static AirportTileSpec tiles[NUM_AIRPORTTILES];
79
80 friend void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts);
81 };
82
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);
88
89 #endif /* NEWGRF_AIRPORTTILES_H */
Airport::type
byte type
Type of this airport,.
Definition: station_base.h:309
ScopeResolver
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope)...
Definition: newgrf_spritegroup.h:291
TileInfo
Tile information, used while rendering the tile.
Definition: tile_cmd.h:44
station_map.h
Maps accessors for stations.
GetTranslatedAirportTileID
StationGfx GetTranslatedAirportTileID(StationGfx gfx)
Do airporttile gfx ID translation for NewGRFs.
Definition: newgrf_airporttiles.cpp:97
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition: newgrf_spritegroup.h:292
VarSpriteGroupScope
VarSpriteGroupScope
Definition: newgrf_spritegroup.h:100
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:310
AirportTileScopeResolver::st
struct Station * st
Station of the airport for which the callback is run, or NULL for build gui.
Definition: newgrf_airporttiles.h:24
newgrf_animation_type.h
Definitions related to NewGRF animation.
CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Definition: newgrf_callbacks.h:24
ResolverObject::GetScope
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Definition: newgrf_spritegroup.cpp:142
AirportTileScopeResolver::airport_id
byte airport_id
Type of airport for which the callback is run.
Definition: newgrf_airporttiles.h:25
airport.h
Various declarations for airports.
newgrf_spritegroup.h
Action 2 handling.
AirportTileResolverObject
Resolver for tiles of an airport.
Definition: newgrf_airporttiles.h:46
GRFFileProps
Data related to the handling of grf files.
Definition: newgrf_commons.h:325
AirportTileSpec::enabled
bool enabled
entity still available (by default true). newgrf can disable it, though
Definition: newgrf_airporttiles.h:69
NUM_AIRPORTTILES
static const uint NUM_AIRPORTTILES
Total number of airport tiles.
Definition: airport.h:25
AirportTileSpec::name
StringID name
Tile Subname string, land information on this tile will give you "AirportName (TileSubname)".
Definition: newgrf_airporttiles.h:66
AirportTileSpec::animation_special_flags
uint8 animation_special_flags
Extra flags to influence the animation.
Definition: newgrf_airporttiles.h:68
CT_INVALID
Invalid cargo type.
Definition: cargo_type.h:70
VSG_SCOPE_SELF
Resolved object itself.
Definition: newgrf_spritegroup.h:103
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
AirportTileScopeResolver::GetVariable
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const
Get a variable value.
Definition: newgrf_airporttiles.cpp:163
AirportTileScopeResolver::GetRandomBits
uint32 GetRandomBits() const
Get a few random bits.
Definition: newgrf_airporttiles.cpp:204
StationGfx
byte StationGfx
Copy from station_map.h.
Definition: newgrf_airport.h:22
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
AirportTileResolverObject::GetScope
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Definition: newgrf_airporttiles.h:52
AirportTileSpec::animation
AnimationInfo animation
Information about the animation.
Definition: newgrf_airporttiles.h:65
AirportTileSpec
Defines the data structure of each individual tile of an airport.
Definition: newgrf_airporttiles.h:64
AirportTileSpec::callback_mask
uint8 callback_mask
Bitmask telling which grf callback is set.
Definition: newgrf_airporttiles.h:67
newgrf_commons.h
This file simplyfies and embeds a common mechanism of loading/saving and mapping of grf entities...
AirportTileScopeResolver::tile
TileIndex tile
Tile for the callback, only valid for airporttile callbacks.
Definition: newgrf_airporttiles.h:26
AirportTileResolverObject::tiles_scope
AirportTileScopeResolver tiles_scope
Scope resolver for the tiles.
Definition: newgrf_airporttiles.h:47
AnimationInfo
Information about animation.
Definition: newgrf_animation_type.h:20
Station::airport
Airport airport
Tile area the airport covers.
Definition: station_base.h:460
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition: newgrf_callbacks.h:22
AirportTileScopeResolver
Scope resolver for handling the tiles of an airport.
Definition: newgrf_airporttiles.h:23
AirportTileScopeResolver::AirportTileScopeResolver
AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st)
Constructor of the scope resolver specific for airport tiles.
Definition: newgrf_airporttiles.h:34
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:22
station_base.h
Base classes/functions for stations.
AirportTileSpec::grf_prop
GRFFileProps grf_prop
properties related the the grf file
Definition: newgrf_airporttiles.h:70
Station
Station data structure.
Definition: station_base.h:446
AirpAnimationTrigger
AirpAnimationTrigger
Animation triggers for airport tiles.
Definition: newgrf_animation_type.h:48