~shevonar/widelands/reworking-menus

« back to all changes in this revision

Viewing changes to src/logic/constructionsite.cc

  • Committer: Shevonar
  • Date: 2013-01-15 23:15:22 UTC
  • mfrom: (6432.1.56 trunk)
  • Revision ID: infomh@anmaruco.de-20130115231522-782njbcagjo6olef
mergedĀ currentĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include <cstdio>
 
21
#include <boost/format.hpp>
21
22
 
22
23
#include "editor_game_base.h"
23
24
#include "i18n.h"
85
86
*/
86
87
std::string ConstructionSite::get_statistics_string()
87
88
{
88
 
        char buffer[40];
89
 
        snprintf
90
 
                (buffer, sizeof(buffer),
91
 
                 _("%u%% built"), (get_built_per64k() * 100) >> 16);
92
 
        return buffer;
 
89
        unsigned int percent = (get_built_per64k() * 100) >> 16;
 
90
 
 
91
        std::string clr = UI_FONT_CLR_OK_HEX;
 
92
        if (percent <= 25) clr = UI_FONT_CLR_BAD_HEX;
 
93
        else if (percent >= 75) clr = UI_FONT_CLR_GOOD_HEX;
 
94
 
 
95
        std::string perc_s = (boost::format("<font color=%s>%i</font>") % clr % percent).str();
 
96
 
 
97
        return (boost::format(_("%s%% built")) % perc_s.c_str()).str();
93
98
}
94
99
 
95
100
/*