OpenTTD
newgrf_railtype.h
Go to the documentation of this file.
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  */
7 
10 #ifndef NEWGRF_RAILTYPE_H
11 #define NEWGRF_RAILTYPE_H
12 
13 #include "rail.h"
14 #include "newgrf_commons.h"
15 #include "newgrf_spritegroup.h"
16 
21 
29  : ScopeResolver(ro), tile(tile), context(context)
30  {
31  }
32 
33  uint32 GetRandomBits() const override;
34  uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
35 };
36 
40 
41  RailTypeResolverObject(const RailtypeInfo *rti, TileIndex tile, TileContext context, RailTypeSpriteGroup rtsg, uint32 param1 = 0, uint32 param2 = 0);
42 
43  ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
44  {
45  switch (scope) {
46  case VSG_SCOPE_SELF: return &this->railtype_scope;
47  default: return ResolverObject::GetScope(scope, relative);
48  }
49  }
50 
51  const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
52 };
53 
55 SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui = false);
56 
57 uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile);
58 
59 #endif /* NEWGRF_RAILTYPE_H */
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope)...
Resolver object for rail types.
SignalType
Type of signal, i.e.
Definition: signal_type.h:23
ResolverObject & ro
Surrounding resolver object.
VarSpriteGroupScope
Interface for SpriteGroup-s to access the gamestate.
Rail specific functions.
SignalState
These are states in which a signal can be.
Definition: signal_type.h:44
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override
Get a variable value.
Resolver for the railtype scope.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0) override
Get a resolver for the scope.
Nothing special.
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
Perform a reverse railtype lookup to get the GRF internal ID.
SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui=false)
Get the sprite to draw for a given signal.
TileContext context
Are we resolving sprites for the upper halftile, or on a bridge?
This struct contains all the info that is needed to draw and construct tracks.
Definition: rail.h:124
Action 2 handling.
uint32 GetRandomBits() const override
Get a few random bits.
TileIndex tile
Tracktile. For track on a bridge this is the southern bridgehead.
Resolved object itself.
RailTypeSpriteGroup
Sprite groups for a railtype.
Definition: rail.h:46
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
RailTypeScopeResolver railtype_scope
Resolver for the railtype scope.
This file simplyfies and embeds a common mechanism of loading/saving and mapping of grf entities...
RailTypeScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context)
Constructor of the railtype scope resolvers.
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context=TCX_NORMAL, uint *num_results=nullptr)
Get the sprite to draw for the given tile.
SignalVariant
Variant of the signal, i.e.
Definition: signal_type.h:16
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:105
TileContext
Context for tile accesses.