1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

selection

This commit is contained in:
Laserlicht
2024-08-13 21:30:54 +02:00
parent 6e6ca16d4e
commit 4f8b965b36
4 changed files with 33 additions and 8 deletions

View File

@@ -168,6 +168,7 @@
"vcmi.statisticWindow.selectView" : "Select view",
"vcmi.statisticWindow.value" : "Value",
"vcmi.statisticWindow.title.overview" : "Overview",
"vcmi.statisticWindow.title.resources" : "Resources",
"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.",

View File

@@ -168,6 +168,7 @@
"vcmi.statisticWindow.selectView" : "Ansicht wählen",
"vcmi.statisticWindow.value" : "Wert",
"vcmi.statisticWindow.title.overview" : "Überblick",
"vcmi.statisticWindow.title.resources" : "Ressourcen",
"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.",

View File

@@ -40,16 +40,18 @@ CStatisticScreen::CStatisticScreen(StatisticDataSet stat)
filledBackground = std::make_shared<FilledTexturePlayerColored>(ImagePath::builtin("DiBoxBck"), Rect(0, 0, pos.w, pos.h));
filledBackground->setPlayerColor(PlayerColor(1));
auto contentArea = Rect(10, 40, 780, 510);
contentArea = Rect(10, 40, 780, 510);
layout.push_back(std::make_shared<CLabel>(400, 20, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->translate("vcmi.statisticWindow.statistic")));
layout.push_back(std::make_shared<TransparentFilledRectangle>(contentArea, ColorRGBA(0, 0, 0, 64), ColorRGBA(64, 80, 128, 255), 1));
layout.push_back(std::make_shared<CButton>(Point(725, 564), AnimationPath::builtin("MUBCHCK"), CButton::tooltip(), [this](){ close(); }, EShortcut::GLOBAL_ACCEPT));
buttonSelect = std::make_shared<CToggleButton>(Point(10, 564), AnimationPath::builtin("GSPBUT2"), CButton::tooltip(), [this](bool on){
std::vector<std::string> texts = { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12" };
GH.windows().createAndPushWindow<StatisticSelector>(texts, [](int selectedIndex)
std::vector<std::string> texts;
for(auto & val : contentText)
texts.push_back(CGI->generaltexth->translate(val));
GH.windows().createAndPushWindow<StatisticSelector>(texts, [this](int selectedIndex)
{
mainContent = getContent((Content)selectedIndex);
});
});
buttonSelect->setTextOverlay(CGI->generaltexth->translate("vcmi.statisticWindow.selectView"), EFonts::FONT_SMALL, Colors::YELLOW);
@@ -60,10 +62,7 @@ CStatisticScreen::CStatisticScreen(StatisticDataSet stat)
});
buttonCsvSave->setTextOverlay(CGI->generaltexth->translate("vcmi.statisticWindow.csvSave"), EFonts::FONT_SMALL, Colors::YELLOW);
//auto plotData = extractData(stat, [](StatisticDataSetEntry val){ return val.resources[EGameResID::GOLD]; });
//mainContent = std::make_shared<LineChart>(contentArea.resize(-5), "Total Gold", plotData);
mainContent = std::make_shared<OverviewPanel>(contentArea.resize(-15), stat);
mainContent = getContent(OVERVIEW);
}
std::map<ColorRGBA, std::vector<float>> CStatisticScreen::extractData(StatisticDataSet stat, std::function<float(StatisticDataSetEntry val)> selector)
@@ -95,6 +94,19 @@ std::map<ColorRGBA, std::vector<float>> CStatisticScreen::extractData(StatisticD
return plotData;
}
std::shared_ptr<CIntObject> CStatisticScreen::getContent(Content c)
{
switch (c)
{
case OVERVIEW:
return std::make_shared<OverviewPanel>(contentArea.resize(-15), statistic);
case CHART_RESOURCES:
auto plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.resources[EGameResID::GOLD]; });
return std::make_shared<LineChart>(contentArea.resize(-5), contentText[c], plotData);
}
}
StatisticSelector::StatisticSelector(std::vector<std::string> texts, std::function<void(int selectedIndex)> cb)
: CWindowObject(BORDERED), texts(texts), cb(cb)
{

View File

@@ -21,14 +21,25 @@ class CSlider;
class CStatisticScreen : public CWindowObject
{
enum Content {
OVERVIEW,
CHART_RESOURCES,
};
std::map<Content, std::string> contentText = {
{ OVERVIEW, "vcmi.statisticWindow.title.overview"},
{ CHART_RESOURCES, "vcmi.statisticWindow.title.resources"},
};
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
std::vector<std::shared_ptr<CIntObject>> layout;
std::shared_ptr<CToggleButton> buttonCsvSave;
std::shared_ptr<CToggleButton> buttonSelect;
StatisticDataSet statistic;
std::shared_ptr<CIntObject> mainContent;
Rect contentArea;
std::map<ColorRGBA, std::vector<float>> extractData(StatisticDataSet stat, std::function<float(StatisticDataSetEntry val)> selector);
std::shared_ptr<CIntObject> getContent(Content c);
public:
CStatisticScreen(StatisticDataSet stat);
};