Use length limit for text only if it's needed.

This check is IMO not needed at all because translators will see if text fit in available area or not. But anyway this length should be large enough.
This commit is contained in:
Deve 2014-10-06 21:53:39 +02:00
parent f828edb445
commit a4ac9f95c2
3 changed files with 8 additions and 3 deletions

View File

@ -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"...");
}

View File

@ -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; }
};
}

View File

@ -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();