diff options
author | yexo <yexo@openttd.org> | 2010-08-05 12:05:15 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-08-05 12:05:15 +0000 |
commit | d6fa76b044711488de9b5ec822d603a4c968dd57 (patch) | |
tree | a5597f39b9e6ad039d06fcf2b589c7eb2768ce03 | |
parent | 5bacbba9f22010b2bd54ebfc7b4cc8713db6c9ea (diff) | |
download | openttd-d6fa76b044711488de9b5ec822d603a4c968dd57.tar.xz |
(svn r20372) -Feature; [NewGRF] callback 0x155 to display extra information about an airport in the build gui
-rw-r--r-- | src/airport_gui.cpp | 30 | ||||
-rw-r--r-- | src/newgrf_callbacks.h | 6 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 2b2730f6d..ee2b96276 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -24,6 +24,7 @@ #include "company_base.h" #include "station_type.h" #include "newgrf_airport.h" +#include "newgrf_callbacks.h" #include "widgets/dropdown_type.h" #include "core/geometry_func.hpp" #include "hotkeys.h" @@ -204,6 +205,7 @@ enum AirportPickerWidgets { BAIRW_LAYOUT_DECREASE, BAIRW_LAYOUT_INCREASE, BAIRW_AIRPORT_SPRITE, + BAIRW_EXTRA_TEXT, BAIRW_BOTTOMPANEL, BAIRW_COVERAGE_LABEL, BAIRW_BTN_DONTHILIGHT, @@ -306,6 +308,22 @@ public: } break; + case BAIRW_EXTRA_TEXT: + for (int i = NEW_AIRPORT_OFFSET; i < NUM_AIRPORTS; i++) { + const AirportSpec *as = AirportSpec::Get(i); + if (!as->enabled) continue; + for (byte layout = 0; layout < as->num_table; layout++) { + StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT); + if (string == STR_UNDEFINED) continue; + + /* STR_BLACK_STRING is used to start the string with {BLACK} */ + SetDParam(0, string); + Dimension d = GetStringMultiLineBoundingBox(STR_BLACK_STRING, *size); + *size = maxdim(d, *size); + } + } + break; + default: break; } } @@ -332,6 +350,17 @@ public: DrawSprite(this->preview_sprite, PAL_NONE, (r.left + r.right - d.width) / 2, (r.top + r.bottom - d.height) / 2); } break; + + case BAIRW_EXTRA_TEXT: + if (_selected_airport_index != -1) { + const AirportSpec *as = GetAirportSpecFromClass(_selected_airport_class, _selected_airport_index); + StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_ADDITIONAL_TEXT); + if (string != STR_UNDEFINED) { + SetDParam(0, string); + DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_BLACK_STRING); + } + } + break; } } @@ -507,6 +536,7 @@ static const NWidgetPart _nested_build_airport_widgets[] = { NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, BAIRW_LAYOUT_INCREASE), SetMinimalSize(12, 0), SetDataTip(AWV_INCREASE, STR_NULL), EndContainer(), NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, BAIRW_AIRPORT_SPRITE), SetFill(1, 0), + NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, BAIRW_EXTRA_TEXT), SetFill(1, 0), SetMinimalSize(150, 0), EndContainer(), /* Bottom panel. */ NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BAIRW_BOTTOMPANEL), SetPIP(2, 2, 2), diff --git a/src/newgrf_callbacks.h b/src/newgrf_callbacks.h index 710592fad..f85bfa859 100644 --- a/src/newgrf_callbacks.h +++ b/src/newgrf_callbacks.h @@ -242,6 +242,12 @@ enum CallbackID { /** Called to indicate how long the current animation frame should last. */ CBID_AIRPTILE_ANIMATION_SPEED = 0x154, // 8 bit callback + + /** + * This callback is called from airport list. It returns a value to be + * used as a custom string ID in the 0xD000 range. + */ + CBID_AIRPORT_ADDITIONAL_TEXT = 0x155, // 15 bit callback }; /** |