summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-08-05 12:04:33 +0000
committeryexo <yexo@openttd.org>2010-08-05 12:04:33 +0000
commit5bacbba9f22010b2bd54ebfc7b4cc8713db6c9ea (patch)
treee68c195043323a8acc2c441562a26bd400c489c5 /src
parenta48dbd7c517e494cfff754caad96d5b2ea2db9e8 (diff)
downloadopenttd-5bacbba9f22010b2bd54ebfc7b4cc8713db6c9ea.tar.xz
(svn r20371) -Codechange: add general function to call text callbacks for airports
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_airport.cpp14
-rw-r--r--src/newgrf_airport.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp
index 20533bc67..d077ae14f 100644
--- a/src/newgrf_airport.cpp
+++ b/src/newgrf_airport.cpp
@@ -349,3 +349,17 @@ uint16 GetAirportCallback(CallbackID callback, uint32 param1, uint32 param2, Sta
return group->GetCallbackResult();
}
+
+StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
+{
+ const SpriteGroup *group;
+ ResolverObject object;
+
+ NewAirportResolver(&object, INVALID_TILE, NULL, as->GetIndex(), layout);
+ object.callback = (CallbackID)callback;
+
+ group = SpriteGroup::Resolve(as->grf_prop.spritegroup, &object);
+ if (group == NULL) return STR_UNDEFINED;
+
+ return GetGRFStringID(as->grf_prop.grffile->grfid, 0xD000 + group->GetResult());
+}
diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h
index 20c6aa046..a20be0f54 100644
--- a/src/newgrf_airport.h
+++ b/src/newgrf_airport.h
@@ -117,4 +117,6 @@ uint GetNumAirportsInClass(AirportClassID id);
void BindAirportSpecs();
const AirportSpec *GetAirportSpecFromClass(AirportClassID aclass, uint airport);
+StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback);
+
#endif /* NEWGRF_AIRPORT_H */