mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-11 11:31:52 +02:00
statistic selection
This commit is contained in:
parent
795a9e131f
commit
504aec3b52
@ -169,6 +169,17 @@
|
||||
"vcmi.statisticWindow.value" : "Value",
|
||||
"vcmi.statisticWindow.title.overview" : "Overview",
|
||||
"vcmi.statisticWindow.title.resources" : "Resources",
|
||||
"vcmi.statisticWindow.title.income" : "Income",
|
||||
"vcmi.statisticWindow.title.numberOfHeroes" : "No. of heroes",
|
||||
"vcmi.statisticWindow.title.numberOfTowns" : "No. of towns",
|
||||
"vcmi.statisticWindow.title.numberOfArtifacts" : "No. of artifacts",
|
||||
"vcmi.statisticWindow.title.numberOfDwellings" : "No. of dwellings",
|
||||
"vcmi.statisticWindow.title.numberOfMines" : "No. of mines",
|
||||
"vcmi.statisticWindow.title.armyStrength" : "army strength",
|
||||
"vcmi.statisticWindow.title.experience" : "experience",
|
||||
"vcmi.statisticWindow.title.resourcesSpentArmy" : "army costs",
|
||||
"vcmi.statisticWindow.title.resourcesSpentBuildings" : "building costs",
|
||||
"vcmi.statisticWindow.title.mapExplored" : "map explored ratio",
|
||||
|
||||
"vcmi.systemOptions.fullscreenBorderless.hover" : "Fullscreen (borderless)",
|
||||
"vcmi.systemOptions.fullscreenBorderless.help" : "{Borderless Fullscreen}\n\nIf selected, VCMI will run in borderless fullscreen mode. In this mode, game will always use same resolution as desktop, ignoring selected resolution.",
|
||||
|
@ -169,6 +169,17 @@
|
||||
"vcmi.statisticWindow.value" : "Wert",
|
||||
"vcmi.statisticWindow.title.overview" : "Überblick",
|
||||
"vcmi.statisticWindow.title.resources" : "Ressourcen",
|
||||
"vcmi.statisticWindow.title.income" : "Einkommen",
|
||||
"vcmi.statisticWindow.title.numberOfHeroes" : "Nr. der Helden",
|
||||
"vcmi.statisticWindow.title.numberOfTowns" : "Nr. der Städte",
|
||||
"vcmi.statisticWindow.title.numberOfArtifacts" : "Nr. der Artefakte",
|
||||
"vcmi.statisticWindow.title.numberOfDwellings" : "Nr. der Behausungen",
|
||||
"vcmi.statisticWindow.title.numberOfMines" : "Nr. der Minen",
|
||||
"vcmi.statisticWindow.title.armyStrength" : "Armeestärke",
|
||||
"vcmi.statisticWindow.title.experience" : "Erfahrung",
|
||||
"vcmi.statisticWindow.title.resourcesSpentArmy" : "Armeekosten",
|
||||
"vcmi.statisticWindow.title.resourcesSpentBuildings" : "Gebäudekosten",
|
||||
"vcmi.statisticWindow.title.mapExplored" : "Maperkundungsrate",
|
||||
|
||||
"vcmi.systemOptions.fullscreenBorderless.hover" : "Vollbild (randlos)",
|
||||
"vcmi.systemOptions.fullscreenBorderless.help" : "{Randloses Vollbild}\n\nWenn diese Option ausgewählt ist, wird VCMI im randlosen Vollbildmodus ausgeführt. In diesem Modus wird das Spiel immer dieselbe Auflösung wie der Desktop verwenden und die gewählte Auflösung ignorieren.",
|
||||
|
@ -112,14 +112,59 @@ std::map<ColorRGBA, std::vector<float>> CStatisticScreen::extractData(StatisticD
|
||||
|
||||
std::shared_ptr<CIntObject> CStatisticScreen::getContent(Content c, EGameResID res)
|
||||
{
|
||||
std::map<ColorRGBA, std::vector<float>> plotData;
|
||||
switch (c)
|
||||
{
|
||||
case OVERVIEW:
|
||||
return std::make_shared<OverviewPanel>(contentArea.resize(-15), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), statistic);
|
||||
|
||||
case CHART_RESOURCES:
|
||||
auto plotData = extractData(statistic, [res](StatisticDataSetEntry val) -> float { return val.resources[res]; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), plotData);
|
||||
plotData = extractData(statistic, [res](StatisticDataSetEntry val) -> float { return val.resources[res]; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])) + " - " + CGI->generaltexth->translate(TextIdentifier("core.restypes", res.getNum()).get()), plotData, 0);
|
||||
|
||||
case CHART_INCOME:
|
||||
plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.income; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), plotData, 0);
|
||||
|
||||
case CHART_NUMBER_OF_HEROES:
|
||||
plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.numberHeroes; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), plotData, 0);
|
||||
|
||||
case CHART_NUMBER_OF_TOWNS:
|
||||
plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.numberTowns; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), plotData, 0);
|
||||
|
||||
case CHART_NUMBER_OF_ARTIFACTS:
|
||||
plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.numberArtifacts; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), plotData, 0);
|
||||
|
||||
case CHART_NUMBER_OF_DWELLINGS:
|
||||
plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.numberDwellings; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), plotData, 0);
|
||||
|
||||
case CHART_NUMBER_OF_MINES:
|
||||
plotData = extractData(statistic, [res](StatisticDataSetEntry val) -> float { return val.numMines[res]; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])) + " - " + CGI->generaltexth->translate(TextIdentifier("core.restypes", res.getNum()).get()), plotData, 0);
|
||||
|
||||
case CHART_ARMY_STRENGTH:
|
||||
plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.armyStrength; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), plotData, 0);
|
||||
|
||||
case CHART_EXPERIENCE:
|
||||
plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.totalExperience; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), plotData, 0);
|
||||
|
||||
case CHART_RESOURCES_SPENT_ARMY:
|
||||
plotData = extractData(statistic, [res](StatisticDataSetEntry val) -> float { return val.spentResourcesForArmy[res]; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])) + " - " + CGI->generaltexth->translate(TextIdentifier("core.restypes", res.getNum()).get()), plotData, 0);
|
||||
|
||||
case CHART_RESOURCES_SPENT_BUILDINGS:
|
||||
plotData = extractData(statistic, [res](StatisticDataSetEntry val) -> float { return val.spentResourcesForBuildings[res]; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])) + " - " + CGI->generaltexth->translate(TextIdentifier("core.restypes", res.getNum()).get()), plotData, 0);
|
||||
|
||||
case CHART_MAP_EXPLORED:
|
||||
plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.mapExploredRatio; });
|
||||
return std::make_shared<LineChart>(contentArea.resize(-5), CGI->generaltexth->translate(std::get<0>(contentInfo[c])), plotData, 1);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -196,7 +241,7 @@ void OverviewPanel::update()
|
||||
content.push_back(std::make_shared<CLabel>(pos.w / 2, 100, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, "blah" + vstd::getDateTimeISO8601Basic(std::time(0))));
|
||||
}
|
||||
|
||||
LineChart::LineChart(Rect position, std::string title, std::map<ColorRGBA, std::vector<float>> data)
|
||||
LineChart::LineChart(Rect position, std::string title, std::map<ColorRGBA, std::vector<float>> data, float maxY)
|
||||
: CIntObject(), maxVal(0), maxDay(0)
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
@ -216,10 +261,12 @@ LineChart::LineChart(Rect position, std::string title, std::map<ColorRGBA, std::
|
||||
((std::shared_ptr<CIntObject>)statusBar)->setEnabled(false);
|
||||
|
||||
// additional calculations
|
||||
bool skipMaxValCalc = maxY > 0;
|
||||
maxVal = maxY;
|
||||
for(auto & line : data)
|
||||
{
|
||||
for(auto & val : line.second)
|
||||
if(maxVal < val)
|
||||
if(maxVal < val && !skipMaxValCalc)
|
||||
maxVal = val;
|
||||
if(maxDay < line.second.size())
|
||||
maxDay = line.second.size();
|
||||
@ -263,7 +310,7 @@ void LineChart::updateStatusBar(const Point & cursorPosition)
|
||||
{
|
||||
float x = ((float)maxDay / (float)chartArea.w) * ((float)cursorPosition.x - (float)r.x) + 1.0f;
|
||||
float y = maxVal - ((float)maxVal / (float)chartArea.h) * ((float)cursorPosition.y - (float)r.y);
|
||||
statusBar->write(CGI->generaltexth->translate("core.genrltxt.64") + ": " + std::to_string((int)x) + " " + CGI->generaltexth->translate("vcmi.statisticWindow.value") + ": " + std::to_string((int)y));
|
||||
statusBar->write(CGI->generaltexth->translate("core.genrltxt.64") + ": " + std::to_string((int)x) + " " + CGI->generaltexth->translate("vcmi.statisticWindow.value") + ": " + ((int)y > 0 ? std::to_string((int)y) : std::to_string(y)));
|
||||
}
|
||||
GH.windows().totalRedraw();
|
||||
}
|
||||
|
@ -24,10 +24,32 @@ class CStatisticScreen : public CWindowObject
|
||||
enum Content {
|
||||
OVERVIEW,
|
||||
CHART_RESOURCES,
|
||||
CHART_INCOME,
|
||||
CHART_NUMBER_OF_HEROES,
|
||||
CHART_NUMBER_OF_TOWNS,
|
||||
CHART_NUMBER_OF_ARTIFACTS,
|
||||
CHART_NUMBER_OF_DWELLINGS,
|
||||
CHART_NUMBER_OF_MINES,
|
||||
CHART_ARMY_STRENGTH,
|
||||
CHART_EXPERIENCE,
|
||||
CHART_RESOURCES_SPENT_ARMY,
|
||||
CHART_RESOURCES_SPENT_BUILDINGS,
|
||||
CHART_MAP_EXPLORED,
|
||||
};
|
||||
std::map<Content, std::tuple<std::string, bool>> contentInfo = { // tuple: textid, resource selection needed
|
||||
{ OVERVIEW, { "vcmi.statisticWindow.title.overview", false } },
|
||||
{ CHART_RESOURCES, { "vcmi.statisticWindow.title.resources", true } },
|
||||
{ OVERVIEW, { "vcmi.statisticWindow.title.overview", false } },
|
||||
{ CHART_RESOURCES, { "vcmi.statisticWindow.title.resources", true } },
|
||||
{ CHART_INCOME, { "vcmi.statisticWindow.title.income", false } },
|
||||
{ CHART_NUMBER_OF_HEROES, { "vcmi.statisticWindow.title.numberOfHeroes", false } },
|
||||
{ CHART_NUMBER_OF_TOWNS, { "vcmi.statisticWindow.title.numberOfTowns", false } },
|
||||
{ CHART_NUMBER_OF_ARTIFACTS, { "vcmi.statisticWindow.title.numberOfArtifacts", false } },
|
||||
{ CHART_NUMBER_OF_DWELLINGS, { "vcmi.statisticWindow.title.numberOfDwellings", false } },
|
||||
{ CHART_NUMBER_OF_MINES, { "vcmi.statisticWindow.title.numberOfMines", true } },
|
||||
{ CHART_ARMY_STRENGTH, { "vcmi.statisticWindow.title.armyStrength", false } },
|
||||
{ CHART_EXPERIENCE, { "vcmi.statisticWindow.title.experience", false } },
|
||||
{ CHART_RESOURCES_SPENT_ARMY, { "vcmi.statisticWindow.title.resourcesSpentArmy", true } },
|
||||
{ CHART_RESOURCES_SPENT_BUILDINGS, { "vcmi.statisticWindow.title.resourcesSpentBuildings", true } },
|
||||
{ CHART_MAP_EXPLORED, { "vcmi.statisticWindow.title.mapExplored", false } },
|
||||
};
|
||||
|
||||
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
|
||||
@ -86,7 +108,7 @@ class LineChart : public CIntObject
|
||||
|
||||
void updateStatusBar(const Point & cursorPosition);
|
||||
public:
|
||||
LineChart(Rect position, std::string title, std::map<ColorRGBA, std::vector<float>> data);
|
||||
LineChart(Rect position, std::string title, std::map<ColorRGBA, std::vector<float>> data, float maxVal);
|
||||
|
||||
void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||
void clickPressed(const Point & cursorPosition) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user