diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.cpp b/src/guiengine/widgets/dynamic_ribbon_widget.cpp index 34fdf011a..a00b2762b 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.cpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.cpp @@ -37,6 +37,7 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row) m_needed_cols = 0; m_col_amount = 0; m_previous_item_count = 0; + m_max_label_length = 0; m_multi_row = multi_row; m_combo = combo; m_has_label = false; @@ -1158,8 +1159,8 @@ float DynamicRibbonWidget::getFontScale(int icon_width) const irr::core::stringw DynamicRibbonWidget::getUserName(const irr::core::stringw& user_name) const { - if (user_name.size() < MAX_LABEL_LENGTH) + if (m_max_label_length == 0 || user_name.size() < m_max_label_length) return user_name; else - return (user_name.subString(0, MAX_LABEL_LENGTH - 3) + L"..."); + return (user_name.subString(0, m_max_label_length - 3) + L"..."); } diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.hpp b/src/guiengine/widgets/dynamic_ribbon_widget.hpp index 96d31af11..b3cdd1396 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.hpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.hpp @@ -187,7 +187,7 @@ namespace GUIEngine int m_max_label_width; /** Max length of a label, in characters */ - static const int MAX_LABEL_LENGTH = 30; + int m_max_label_length; public: @@ -298,6 +298,9 @@ namespace GUIEngine /** Set approximately how many items are expected to be in this ribbon; will help the layout * algorithm next time add() is called */ void setItemCountHint(int hint) { m_item_count_hint = hint; } + + /** Set max length of displayed text. */ + void setMaxLabelLength(int length) { m_max_label_length = length; } }; } diff --git a/src/states_screens/tracks_screen.cpp b/src/states_screens/tracks_screen.cpp index 9e25c46d4..793834c54 100644 --- a/src/states_screens/tracks_screen.cpp +++ b/src/states_screens/tracks_screen.cpp @@ -171,6 +171,7 @@ void TracksScreen::init() // Reset GP list everytime (accounts for locking changes, etc.) gps_widget->clearItems(); + gps_widget->setMaxLabelLength(30); // Ensure that no GP and no track is NULL grand_prix_manager->checkConsistency();