diff --git a/src/guiengine/scalable_font.cpp b/src/guiengine/scalable_font.cpp index 5fcddfea5..26cf20c3f 100644 --- a/src/guiengine/scalable_font.cpp +++ b/src/guiengine/scalable_font.cpp @@ -500,15 +500,12 @@ void ScalableFont::draw(const core::stringw& text, core::position2d offset = position.UpperLeftCorner; core::dimension2d text_dimension; - // When we use the "tab" hack, disable right-alignment, it messes up everything - bool has_tab = (text.findFirst(L'\t') != -1); - - if ((m_rtl && !has_tab) || hcenter || vcenter || clip) + if (m_rtl || hcenter || vcenter || clip) { text_dimension = getDimension(text.c_str()); - if (hcenter) offset.X += (position.getWidth() - text_dimension.Width) / 2; - else if (m_rtl && !has_tab) offset.X += (position.getWidth() - text_dimension.Width); + if (hcenter) offset.X += (position.getWidth() - text_dimension.Width) / 2; + else if (m_rtl) offset.X += (position.getWidth() - text_dimension.Width); if (vcenter) offset.Y += (position.getHeight() - text_dimension.Height) / 2; if (clip) @@ -519,14 +516,6 @@ void ScalableFont::draw(const core::stringw& text, } } - if (m_rtl && has_tab) - { - const int where = text.findFirst(L'\t'); - core::stringw substr = text.subString(0, where-1); - text_dimension = getDimension(substr.c_str()) + getDimension(L"XX"); - offset.X += (int)(position.getWidth()*m_tab_stop-text_dimension.Width); - } - // ---- collect character locations const unsigned int text_size = text.size(); core::array indices(text_size); diff --git a/src/guiengine/widgets/CGUISTKListBox.cpp b/src/guiengine/widgets/CGUISTKListBox.cpp index 0a4a55e8d..f73d1de0a 100644 --- a/src/guiengine/widgets/CGUISTKListBox.cpp +++ b/src/guiengine/widgets/CGUISTKListBox.cpp @@ -488,7 +488,7 @@ void CGUISTKListBox::draw() { total_proportion += Items[i].m_contents[x].m_proportion; } - int part_size = textRect.getWidth() / total_proportion; + int part_size = (int)(textRect.getWidth() / float(total_proportion)); for(int x = 0; x < Items[i].m_contents.size(); ++x) { @@ -532,7 +532,7 @@ void CGUISTKListBox::draw() textRect, hasItemOverrideColor(i, EGUI_LBC_TEXT_HIGHLIGHT) ? getItemOverrideColor(i, EGUI_LBC_TEXT_HIGHLIGHT) : getItemDefaultColor(EGUI_LBC_TEXT_HIGHLIGHT), - false, true, &clientClip); + Items[i].m_contents[x].m_center, true, &clientClip); } else { @@ -540,7 +540,7 @@ void CGUISTKListBox::draw() Items[i].m_contents[x].m_text.c_str(), textRect, hasItemOverrideColor(i, EGUI_LBC_TEXT) ? getItemOverrideColor(i, EGUI_LBC_TEXT) : getItemDefaultColor(EGUI_LBC_TEXT), - false, true, &clientClip); + Items[i].m_contents[x].m_center, true, &clientClip); } //Position back to inital pos textRect.UpperLeftCorner.X -= ItemsIconWidth+6; diff --git a/src/guiengine/widgets/CGUISTKListBox.h b/src/guiengine/widgets/CGUISTKListBox.h index b8e3fa662..e8edeb151 100644 --- a/src/guiengine/widgets/CGUISTKListBox.h +++ b/src/guiengine/widgets/CGUISTKListBox.h @@ -32,12 +32,14 @@ namespace irr irr::core::stringw m_text; int m_proportion; s32 m_icon; + bool m_center; - ListCell(irr::core::stringw text, s32 icon = -1, int proportion = 1) + ListCell(irr::core::stringw text, s32 icon = -1, int proportion = 1, bool center = false) { m_text = text; m_proportion = proportion; m_icon = icon; + m_center = center; } }; diff --git a/src/guiengine/widgets/list_widget.cpp b/src/guiengine/widgets/list_widget.cpp index 4998ed27d..3d82cd5f5 100644 --- a/src/guiengine/widgets/list_widget.cpp +++ b/src/guiengine/widgets/list_widget.cpp @@ -182,12 +182,13 @@ void ListWidget::clear() void ListWidget::addItem( const std::string& internal_name, const irr::core::stringw &name, - const int icon) + const int icon, + bool center) { // May only be called AFTER this widget has been add()ed assert(m_element != NULL); - ListCell cell(name, icon); + ListCell cell(name, icon, 1, center); ListItem newItem; newItem.m_internal_name = internal_name; newItem.m_contents.push_back(cell); diff --git a/src/guiengine/widgets/list_widget.hpp b/src/guiengine/widgets/list_widget.hpp index 657adbac8..d74937a77 100644 --- a/src/guiengine/widgets/list_widget.hpp +++ b/src/guiengine/widgets/list_widget.hpp @@ -122,7 +122,8 @@ namespace GUIEngine */ void addItem( const std::string& internal_name, const irr::core::stringw &name, - const int icon=-1); + const int icon=-1, + bool center = false); void addItem( const std::string& internal_name, PtrVector * contents); diff --git a/src/states_screens/addons_screen.cpp b/src/states_screens/addons_screen.cpp index 99636dfc5..7450f8cbd 100644 --- a/src/states_screens/addons_screen.cpp +++ b/src/states_screens/addons_screen.cpp @@ -104,7 +104,7 @@ void AddonsScreen::beforeAddingWidget() getWidget("list_addons"); assert(w_list != NULL); w_list->clearColumns(); - w_list->addColumn( _("Add-on name"), 2 ); + w_list->addColumn( _("Add-on name"), 3 ); w_list->addColumn( _("Updated date"), 1 ); GUIEngine::SpinnerWidget* w_filter_date = @@ -358,8 +358,8 @@ void AddonsScreen::loadList() } PtrVector * row = new PtrVector; - row->push_back(new GUIEngine::ListWidget::ListCell(s.c_str(),icon,2)); - row->push_back(new GUIEngine::ListWidget::ListCell(addon->getDateAsString().c_str(),-1,1)); + row->push_back(new GUIEngine::ListWidget::ListCell(s.c_str(), icon, 3, false)); + row->push_back(new GUIEngine::ListWidget::ListCell(addon->getDateAsString().c_str(), -1, 1, true)); w_list->addItem(addon->getId(), row); // Highlight if it's not approved in artists debug mode. diff --git a/src/states_screens/server_selection.cpp b/src/states_screens/server_selection.cpp index 351844d1f..027bc202b 100644 --- a/src/states_screens/server_selection.cpp +++ b/src/states_screens/server_selection.cpp @@ -109,7 +109,7 @@ void ServerSelection::loadList(bool refresh) num_players.append(StringUtils::toWString(server->getMaxPlayers())); PtrVector * row = new PtrVector; row->push_back(new GUIEngine::ListWidget::ListCell(server->getName(),-1,3)); - row->push_back(new GUIEngine::ListWidget::ListCell(num_players,-1,1)); + row->push_back(new GUIEngine::ListWidget::ListCell(num_players,-1,1,true)); m_server_list_widget->addItem("server", row); }