OpenTTD

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