diff options
author | frosch <frosch@openttd.org> | 2013-10-28 12:59:44 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-10-28 12:59:44 +0000 |
commit | eaafbb00ed8bc41ad2d3cee5c99b3e92cd9b7971 (patch) | |
tree | 543a072271423c7f27147152f15473e9c69830be /src | |
parent | f0fbe7767da7b998d0dd13aa7c37117f333e8f43 (diff) | |
download | openttd-eaafbb00ed8bc41ad2d3cee5c99b3e92cd9b7971.tar.xz |
(svn r25927) -Fix [FS#5733]: Consider size of signal sprites for sizing the signal GUI. (based on patch by adf88)
Diffstat (limited to 'src')
-rw-r--r-- | src/rail_gui.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 69b15e085..713a94c05 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1452,6 +1452,8 @@ static void ShowStationBuilder(Window *parent) struct BuildSignalWindow : public PickerWindowBase { private: + Dimension sig_sprite_size; ///< Maximum size of signal GUI sprites. + /** * Draw dynamic a signal-sprite in a button in the signal GUI * Draw the sprite +1px to the right and down if the button is lowered @@ -1495,6 +1497,29 @@ public: _convert_signal_button = false; } + virtual void OnInit() + { + /* Calculate maximum signal sprite size. */ + this->sig_sprite_size.width = 0; + this->sig_sprite_size.height = 0; + const RailtypeInfo *rti = GetRailTypeInfo(_cur_railtype); + for (uint type = SIGTYPE_NORMAL; type < SIGTYPE_END; type++) { + for (uint variant = SIG_ELECTRIC; variant <= SIG_SEMAPHORE; variant++) { + for (uint lowered = 0; lowered < 2; lowered++) { + this->sig_sprite_size = maxdim(this->sig_sprite_size, GetSpriteSize(rti->gui_sprites.signals[type][variant][lowered])); + } + } + } + } + + virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + { + if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) { + size->width = max(size->width, this->sig_sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT); + size->height = max(size->height, this->sig_sprite_size.height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM); + } + } + virtual void SetStringParameters(int widget) const { switch (widget) { |