From d4e8e1afa6374b6117855e4d6bfea5cff00a75b7 Mon Sep 17 00:00:00 2001 From: Ihar Hubchyk Date: Sun, 11 Oct 2026 20:25:48 +0800 Subject: [PATCH] Small improvements for High Scores dialog relates to #9716 --- src/fheroes2/game/game_highscores.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/game/game_highscores.cpp b/src/fheroes2/game/game_highscores.cpp index 7cd538b4c..cede1d038 100644 --- a/src/fheroes2/game/game_highscores.cpp +++ b/src/fheroes2/game/game_highscores.cpp @@ -73,7 +73,7 @@ namespace fheroes2 namespace { - const std::string highScoreFileName = "fheroes2.hgs"; + const std::string_view highScoreFileName{ "fheroes2.hgs" }; fheroes2::HighScoreDataContainer highScoreDataContainer; const int32_t initialHighScoreEntryOffsetY = 72; const int32_t highScoreEntryStepY = 40; @@ -85,6 +85,8 @@ namespace const int32_t monsterOffsetX = 554; const int32_t monsterOffsetY = 91; + constexpr size_t maxDisplayedEntries{ 10 }; + // Calculate the mini monster sprites ROI. fheroes2::Rect getAnimationRoi( const fheroes2::Point & position, const bool isCampaign ) { @@ -203,7 +205,11 @@ namespace int32_t scoreIndex = 0; int32_t offsetY = position.y; - for ( const fheroes2::HighscoreData & data : highScores ) { + const size_t entryCount{ std::min( maxDisplayedEntries, highScores.size() ) }; + + for ( size_t i = 0; i < entryCount; ++i ) { + const fheroes2::HighscoreData & data = highScores[i]; + const fheroes2::FontType font = ( scoreIndex == selectedScoreIndex ) ? fheroes2::FontType::normalYellow() : fheroes2::FontType::normalWhite(); // TODO: scenario name can have its own independent language.