/* * CStatisticScreen.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * */ #pragma once #include "../windows/CWindowObject.h" #include "../../lib/gameState/GameStatistics.h" class FilledTexturePlayerColored; class CToggleButton; class GraphicalPrimitiveCanvas; class LineChart; class CGStatusBar; class ComboBox; class CSlider; class IImage; class CPicture; using TData = std::vector>>; using TIcons = std::vector, std::string>>; // Color, Day, Image, Helptext 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> contentInfo = { // tuple: textid, resource selection needed { 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 filledBackground; std::vector> layout; std::shared_ptr buttonCsvSave; std::shared_ptr buttonSelect; StatisticDataSet statistic; std::shared_ptr mainContent; Rect contentArea; using ExtractFunctor = std::function; TData extractData(const StatisticDataSet & stat, const ExtractFunctor & selector) const; TIcons extractIcons() const; std::shared_ptr getContent(Content c, EGameResID res); void onSelectButton(); public: CStatisticScreen(const StatisticDataSet & stat); static std::string getDay(int day); }; class StatisticSelector : public CWindowObject { std::shared_ptr filledBackground; std::vector> buttons; std::shared_ptr slider; const int LINES = 10; std::vector texts; std::function cb; void update(int to); public: StatisticSelector(const std::vector & texts, const std::function & cb); }; class OverviewPanel : public CIntObject { std::shared_ptr canvas; std::vector> layout; std::vector> content; std::shared_ptr slider; Point fieldSize; StatisticDataSet data; std::vector>> dataExtract; const int LINES = 15; const int Y_OFFS = 30; std::vector playerDataFilter(PlayerColor color); void update(int to); public: OverviewPanel(Rect position, std::string title, const StatisticDataSet & stat); }; class LineChart : public CIntObject { std::shared_ptr canvas; std::vector> layout; std::shared_ptr statusBar; std::vector> pictures; Rect chartArea; float maxVal; int niceMaxVal; int maxDay; void updateStatusBar(const Point & cursorPosition); public: LineChart(Rect position, std::string title, TData data, TIcons icons, float maxY); void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) override; void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override; };