From 401ebed03a1f66c356984d9802dcec97027b6c99 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 12 Jun 2025 18:27:16 +0100 Subject: [PATCH] Add: Show and sort online content version in list. (#14355) --- src/network/network_content_gui.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index abba86f0d6..cf4952861e 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -426,7 +426,9 @@ class NetworkContentListWindow : public Window, ContentCallback { /** Sort content by name. */ static bool NameSorter(const ContentInfo * const &a, const ContentInfo * const &b) { - return StrNaturalCompare(a->name, b->name, true) < 0; // Sort by name (natural sorting). + int r = StrNaturalCompare(a->name, b->name, true); // Sort by name (natural sorting). + if (r == 0) r = StrNaturalCompare(a->version, b->version, true); + return r < 0; } /** Sort content by type. */ @@ -637,6 +639,7 @@ public: */ void DrawMatrix(const Rect &r) const { + bool rtl = _current_text_dir == TD_RTL; const Rect checkbox = this->GetWidget(WID_NCL_CHECKBOX)->GetCurrentRect(); const Rect name = this->GetWidget(WID_NCL_NAME)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect); const Rect type = this->GetWidget(WID_NCL_TYPE)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect); @@ -644,6 +647,7 @@ public: /* Fill the matrix with the information */ const uint step_height = this->GetWidget(WID_NCL_MATRIX)->resize_y; const int text_y_offset = WidgetDimensions::scaled.matrix.top + (step_height - WidgetDimensions::scaled.matrix.Vertical() - GetCharacterHeight(FS_NORMAL)) / 2; + const int version_y_offset = WidgetDimensions::scaled.matrix.top + (step_height - WidgetDimensions::scaled.matrix.Vertical() - GetCharacterHeight(FS_SMALL)) / 2; Rect mr = r.WithHeight(step_height); auto [first, last] = this->vscroll->GetVisibleRangeIterators(this->content); @@ -667,7 +671,10 @@ public: StringID str = STR_CONTENT_TYPE_BASE_GRAPHICS + ci->type - CONTENT_TYPE_BASE_GRAPHICS; DrawString(type.left, type.right, mr.top + text_y_offset, str, TC_BLACK, SA_HOR_CENTER); - DrawString(name.left, name.right, mr.top + text_y_offset, ci->name, TC_BLACK); + int x = DrawString(name.left, name.right, mr.top + version_y_offset, ci->version, TC_BLACK, SA_RIGHT, false, FS_SMALL); + x += rtl ? WidgetDimensions::scaled.hsep_wide : -WidgetDimensions::scaled.hsep_wide; + + DrawString(rtl ? x : name.left, rtl ? name.right : x, mr.top + text_y_offset, ci->name, TC_BLACK); mr = mr.Translate(0, step_height); } }