From 6e2952812428448c6cb119656fb9cc686c4a5fdb Mon Sep 17 00:00:00 2001
From: nexusmrsep <39925111+nexusmrsep@users.noreply.github.com>
Date: Sun, 19 Jul 2020 10:22:52 +0200
Subject: [PATCH] Re-colorize achievements UI (#42228)

---
 src/achievement.cpp          | 19 ++++++++++++-------
 src/scores_ui.cpp            | 10 ++++++----
 tests/stats_tracker_test.cpp |  4 ++--
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/achievement.cpp b/src/achievement.cpp
index b96b914ff4815..dd5904dc778e2 100644
--- a/src/achievement.cpp
+++ b/src/achievement.cpp
@@ -124,11 +124,11 @@ std::string enum_to_string<requirement_visibility>( requirement_visibility data
 
 } // namespace io
 
-static nc_color color_from_completion( bool is_conduct, achievement_completion comp )
+static nc_color color_from_completion( bool is_conduct, achievement_completion comp, bool is_title )
 {
     switch( comp ) {
         case achievement_completion::pending:
-            return is_conduct ? c_light_green : c_yellow;
+            return is_conduct ? c_light_green : ( is_title ? c_white : c_light_cyan );
         case achievement_completion::completed:
             return c_light_green;
         case achievement_completion::failed:
@@ -325,7 +325,7 @@ std::string achievement::time_bound::ui_text( bool is_conduct ) const
     time_point now = calendar::turn;
     achievement_completion comp = completed();
 
-    nc_color c = color_from_completion( is_conduct, comp );
+    nc_color c = color_from_completion( is_conduct, comp, false );
 
     auto translate_epoch = []( epoch e ) {
         switch( e ) {
@@ -570,8 +570,9 @@ std::string enum_to_string<achievement_completion>( achievement_completion data
 std::string achievement_state::ui_text( const achievement *ach ) const
 {
     // First: the achievement name and description
-    nc_color c = color_from_completion( ach->is_conduct(), completion );
-    std::string result = colorize( ach->name(), c ) + "\n";
+    nc_color c = color_from_completion( ach->is_conduct(), completion, false );
+    nc_color c_title = color_from_completion( ach->is_conduct(), completion, true );
+    std::string result = colorize( ach->name(), c_title ) + "\n";
     if( !ach->description().empty() ) {
         result += "  " + colorize( ach->description(), c ) + "\n";
     }
@@ -696,8 +697,12 @@ std::string achievement_tracker::ui_text() const
 
     // First: the achievement name and description
     nc_color c = color_from_completion( achievement_->is_conduct(),
-                                        achievement_completion::pending );
-    std::string result = colorize( achievement_->name(), c ) + "\n";
+                                        achievement_completion::pending,
+                                        false );
+    nc_color c_title = color_from_completion( achievement_->is_conduct(),
+                       achievement_completion::pending,
+                       true );
+    std::string result = colorize( achievement_->name(), c_title ) + "\n";
     if( !achievement_->description().empty() ) {
         result += "  " + colorize( achievement_->description(), c ) + "\n";
     }
diff --git a/src/scores_ui.cpp b/src/scores_ui.cpp
index 5dab52482da32..7de86caa72296 100644
--- a/src/scores_ui.cpp
+++ b/src/scores_ui.cpp
@@ -19,7 +19,7 @@
 #include "ui_manager.h"
 
 static std::string get_achievements_text( const achievements_tracker &achievements,
-        bool use_conducts )
+        bool use_conducts, int width )
 {
     std::string thing_name = use_conducts ? _( "conducts" ) : _( "achievements" );
     std::string cap_thing_name = use_conducts ? _( "Conducts" ) : _( "Achievements" );
@@ -47,8 +47,10 @@ static std::string get_achievements_text( const achievements_tracker &achievemen
         return std::make_tuple( comp, ach->name().translated(), ach );
     } );
     std::sort( sortable_achievements.begin(), sortable_achievements.end(), localized_compare );
+    char ch = string_from_int( LINE_OXOX ).at( 0 );
     for( const sortable_achievement &ach : sortable_achievements ) {
-        os += achievements.ui_text_for( std::get<const achievement *>( ach ) ) + "\n";
+        os += achievements.ui_text_for( std::get<const achievement *>( ach ) );
+        os += colorize( std::string( width, ch ), c_magenta );
     }
     if( valid_achievements.empty() ) {
         os += string_format( _( "This game has no valid %s.\n" ), thing_name );
@@ -132,10 +134,10 @@ void show_scores_ui( const achievements_tracker &achievements, stats_tracker &st
         if( new_tab ) {
             switch( tab ) {
                 case tab_mode::achievements:
-                    view.set_text( get_achievements_text( achievements, false ) );
+                    view.set_text( get_achievements_text( achievements, false, getmaxx( w ) - 2 ) );
                     break;
                 case tab_mode::conducts:
-                    view.set_text( get_achievements_text( achievements, true ) );
+                    view.set_text( get_achievements_text( achievements, true, getmaxx( w ) - 2 ) );
                     break;
                 case tab_mode::scores:
                     view.set_text( get_scores_text( stats ) );
diff --git a/tests/stats_tracker_test.cpp b/tests/stats_tracker_test.cpp
index ca4ae73ea3d37..2266f9fefa2ad 100644
--- a/tests/stats_tracker_test.cpp
+++ b/tests/stats_tracker_test.cpp
@@ -638,11 +638,11 @@ TEST_CASE( "achievments_tracker", "[stats]" )
         send_game_start( b, u_id );
 
         CHECK( a.ui_text_for( &*a_kill_zombie ) ==
-               "<color_c_yellow>One down, billions to go…</color>\n"
+               "<color_c_white>One down, billions to go…</color>\n"
                "  <color_c_yellow>0/1 zombie killed</color>\n" );
         if( time_since_game_start < 1_minutes ) {
             CHECK( a.ui_text_for( &*a_kill_in_first_minute ) ==
-                   "<color_c_yellow>Rude awakening</color>\n"
+                   "<color_c_white>Rude awakening</color>\n"
                    "  <color_c_light_green>Within 1 minute of start of game (30 seconds remaining)</color>\n"
                    "  <color_c_yellow>0/1 monster killed</color>\n" );
         } else {