Mercurial > hg > openttd
changeset 11980:625d07ed57cd draft
(svn r16386) -Codechange: Move ShowAdditionalText() to build_vehicle_gui and make it static.
author | frosch <frosch@openttd.org> |
---|---|
date | Fri, 22 May 2009 19:47:26 +0000 |
parents | 6c50c7cd27fb |
children | cf1aad9b971c |
files | src/build_vehicle_gui.cpp src/vehicle_gui.cpp src/vehicle_gui.h |
diffstat | 3 files changed, 22 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -12,6 +12,7 @@ #include "company_func.h" #include "vehicle_gui.h" #include "newgrf_engine.h" +#include "newgrf_text.h" #include "group.h" #include "strings_func.h" #include "window_func.h" @@ -591,6 +592,27 @@ } /** + * Display additional text from NewGRF in the purchase information window + * @param left Left border of text bounding box + * @param right Right border of text bounding box + * @param y Top border of text bounding box + * @param engine Engine to query the additional purchase information for + * @return Bottom border of text bounding box + */ +static uint ShowAdditionalText(int left, int right, int y, EngineID engine) +{ + uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, NULL); + if (callback == CALLBACK_FAILED) return y; + + /* STR_BLACK_STRING is used to start the string with {BLACK} */ + SetDParam(0, GetGRFStringID(GetEngineGRFID(engine), 0xD000 + callback)); + PrepareTextRefStackUsage(0); + uint result = DrawStringMultiLine(left, right, y, INT32_MAX, STR_BLACK_STRING); + StopTextRefStackUsage(); + return result; +} + +/** * Draw the purchase info details of a vehicle at a given location. * @param left,right,y location where to draw the info * @param engine_number the engine of which to draw the info of
--- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -459,20 +459,6 @@ w->parent = parent; } -/** Display additional text from NewGRF in the purchase information window */ -uint ShowAdditionalText(int left, int right, int y, EngineID engine) -{ - uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, NULL); - if (callback == CALLBACK_FAILED) return y; - - /* STR_BLACK_STRING is used to start the string with {BLACK} */ - SetDParam(0, GetGRFStringID(GetEngineGRFID(engine), 0xD000 + callback)); - PrepareTextRefStackUsage(0); - uint result = DrawStringMultiLine(left, right, y, INT32_MAX, STR_BLACK_STRING); - StopTextRefStackUsage(); - return result; -} - /** Display list of cargo types of the engine, for the purchase information window */ uint ShowRefitOptionsList(int left, int right, int y, EngineID engine) {
--- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -60,7 +60,6 @@ void ShowBuildVehicleWindow(TileIndex tile, VehicleType type); -uint ShowAdditionalText(int left, int right, int y, EngineID engine); uint ShowRefitOptionsList(int left, int right, int y, EngineID engine); StringID GetCargoSubtypeText(const Vehicle *v);