From 85ac0f88567c746c60c4f02683e085b3a73d6870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 10 Sep 2021 01:13:01 +0200 Subject: [PATCH] Fix a couple sort comparators for the savedata screen --- UI/SavedataScreen.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index 1c44d8127c..747ebd5edc 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -317,13 +317,13 @@ void SavedataButton::Draw(UIContext &dc) { int availableWidth = bounds_.w - 150; float sineWidth = std::max(0.0f, (tw - availableWidth)) / 2.0f; - float tx = 150; + float tx = 150.0f; if (availableWidth < tw) { float overageRatio = 1.5f * availableWidth * 1.0f / tw; tx -= (1.0f + sin(time_now_d() * overageRatio)) * sineWidth; Bounds tb = bounds_; - tb.x = bounds_.x + 150; - tb.w = bounds_.w - 150; + tb.x = bounds_.x + 150.0f; + tb.w = std::max(1.0f, bounds_.w - 150.0f); dc.PushScissor(tb); } dc.DrawText(title_.c_str(), bounds_.x + tx, bounds_.y + 4, style.fgColor, ALIGN_TOPLEFT); @@ -443,6 +443,8 @@ bool SavedataBrowser::BySize(const UI::View *v1, const UI::View *v2) { if (GetTotalSize(b1) > GetTotalSize(b2)) return true; + else if (GetTotalSize(b1) < GetTotalSize(b2)) + return false; return strcmp(b1->GamePath().c_str(), b2->GamePath().c_str()) < 0; } @@ -469,6 +471,8 @@ bool SavedataBrowser::ByDate(const UI::View *v1, const UI::View *v2) { if (GetDateSeconds(b1) > GetDateSeconds(b2)) return true; + if (GetDateSeconds(b1) < GetDateSeconds(b2)) + return false; return strcmp(b1->GamePath().c_str(), b2->GamePath().c_str()) < 0; }