[CChart] Add a percentage format and round displayed integers
Reviewed by: bb Approved by: Vladislav Differential Revision: https://code.wildfiregames.com/D1878 This was SVN commit r22282.
This commit is contained in:
parent
f0f06deaf3
commit
621bb1367a
@ -151,7 +151,7 @@ var getScorePanelsData = () => ({
|
||||
"headings": [
|
||||
{ "identifier": "playername", "caption": translate("Player name"), "yStart": 26, "width": 200 },
|
||||
{ "identifier": "tradeIncome", "caption": translate("Trade income"), "yStart": 16, "width": 100 },
|
||||
{ "identifier": "barterEfficency", "caption": translate("Barter efficiency"), "yStart": 16, "width": 100 },
|
||||
{ "identifier": "barterEfficency", "caption": translate("Barter efficiency"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
||||
...g_ResourceData.GetResources().map(res => {
|
||||
return {
|
||||
"identifier": res.code,
|
||||
@ -183,11 +183,11 @@ var getScorePanelsData = () => ({
|
||||
"headings": [
|
||||
{ "identifier": "playername", "caption": translate("Player name"), "yStart": 26, "width": 200 },
|
||||
{ "identifier": "killDeath", "caption": translate("Kill / Death ratio"), "yStart": 16, "width": 100, "format": "DECIMAL2" },
|
||||
{ "identifier": "mapControlPeak", "caption": translate("Map control (peak)"), "yStart": 16, "width": 100 },
|
||||
{ "identifier": "mapControl", "caption": translate("Map control (finish)"), "yStart": 16, "width": 100 },
|
||||
{ "identifier": "mapExploration", "caption": translate("Map exploration"), "yStart": 16, "width": 100 },
|
||||
{ "identifier": "vegetarianRatio", "caption": translate("Vegetarian ratio"), "yStart": 16, "width": 100 },
|
||||
{ "identifier": "feminization", "caption": translate("Feminization"), "yStart": 16, "width": 100 },
|
||||
{ "identifier": "mapControlPeak", "caption": translate("Map control (peak)"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
||||
{ "identifier": "mapControl", "caption": translate("Map control (finish)"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
||||
{ "identifier": "mapExploration", "caption": translate("Map exploration"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
||||
{ "identifier": "vegetarianRatio", "caption": translate("Vegetarian ratio"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
||||
{ "identifier": "feminization", "caption": translate("Feminization"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
||||
{
|
||||
"identifier": "bribes",
|
||||
"caption": translate("Bribes"),
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2018 Wildfire Games.
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -270,7 +270,7 @@ CSize CChart::AddFormattedValue(const CStrW& format, const float value, const CS
|
||||
else if (format == L"INTEGER")
|
||||
{
|
||||
wchar_t buffer[64];
|
||||
swprintf(buffer, 64, L"%d", static_cast<int>(value));
|
||||
swprintf(buffer, 64, L"%d", std::lround(value));
|
||||
gui_str.SetValue(buffer);
|
||||
}
|
||||
else if (format == L"DURATION_SHORT")
|
||||
@ -280,6 +280,12 @@ CSize CChart::AddFormattedValue(const CStrW& format, const float value, const CS
|
||||
swprintf(buffer, 64, L"%d:%02d", seconds / 60, seconds % 60);
|
||||
gui_str.SetValue(buffer);
|
||||
}
|
||||
else if (format == L"PERCENTAGE")
|
||||
{
|
||||
wchar_t buffer[64];
|
||||
swprintf(buffer, 64, L"%d%%", std::lround(value));
|
||||
gui_str.SetValue(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGERROR("Unsupported chart format: " + format.EscapeToPrintableASCII());
|
||||
|
Loading…
Reference in New Issue
Block a user