mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-18 19:19:29 +01:00
Add: Show and sort online content version in list. (#14355)
This commit is contained in:
parent
b012d9e3dc
commit
401ebed03a
@ -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<NWidgetBase>(WID_NCL_CHECKBOX)->GetCurrentRect();
|
||||
const Rect name = this->GetWidget<NWidgetBase>(WID_NCL_NAME)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
|
||||
const Rect type = this->GetWidget<NWidgetBase>(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<NWidgetBase>(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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user