diff --git a/client/mainmenu/CStatisticScreen.cpp b/client/mainmenu/CStatisticScreen.cpp index ab74eccc9..75edef81f 100644 --- a/client/mainmenu/CStatisticScreen.cpp +++ b/client/mainmenu/CStatisticScreen.cpp @@ -47,11 +47,22 @@ CStatisticScreen::CStatisticScreen(StatisticDataSet stat) buttonSelect = std::make_shared(Point(10, 564), AnimationPath::builtin("GSPBUT2"), CButton::tooltip(), [this](bool on){ std::vector texts; - for(auto & val : contentText) - texts.push_back(CGI->generaltexth->translate(val)); + for(auto & val : contentInfo) + texts.push_back(CGI->generaltexth->translate(std::get<0>(val.second))); GH.windows().createAndPushWindow(texts, [this](int selectedIndex) { - mainContent = getContent((Content)selectedIndex); + OBJECT_CONSTRUCTION; + if(!std::get<1>(contentInfo[(Content)selectedIndex])) + mainContent = getContent((Content)selectedIndex); + else + { + auto content = (Content)selectedIndex; + GH.windows().createAndPushWindow(std::vector({"gold", "bla", "blab"}), [this, content](int selectedIndex) + { + OBJECT_CONSTRUCTION; + mainContent = getContent((Content)selectedIndex); + }); + } }); }); buttonSelect->setTextOverlay(CGI->generaltexth->translate("vcmi.statisticWindow.selectView"), EFonts::FONT_SMALL, Colors::YELLOW); @@ -103,8 +114,10 @@ std::shared_ptr CStatisticScreen::getContent(Content c) case CHART_RESOURCES: auto plotData = extractData(statistic, [](StatisticDataSetEntry val) -> float { return val.resources[EGameResID::GOLD]; }); - return std::make_shared(contentArea.resize(-5), contentText[c], plotData); + return std::make_shared(contentArea.resize(-5), std::get<0>(contentInfo[c]), plotData); } + + return nullptr; } StatisticSelector::StatisticSelector(std::vector texts, std::function cb) @@ -131,7 +144,7 @@ void StatisticSelector::update(int to) if(i>=texts.size()) continue; - auto button = std::make_shared(Point(0, 10 + (i - to) * 40), AnimationPath::builtin("GSPBUT2"), CButton::tooltip(), [this, i](bool on){ cb(i); close(); }); + auto button = std::make_shared(Point(0, 10 + (i - to) * 40), AnimationPath::builtin("GSPBUT2"), CButton::tooltip(), [this, i](bool on){ close(); cb(i); }); button->setTextOverlay(texts[i], EFonts::FONT_SMALL, Colors::WHITE); buttons.push_back(button); } @@ -161,6 +174,7 @@ OverviewPanel::OverviewPanel(Rect position, StatisticDataSet data) void OverviewPanel::update() { + canvas->clear(); Point fieldSize(canvas->pos.w / (graphics->playerColors.size() + 2), canvas->pos.h / LINES); for(int x = 0; x < graphics->playerColors.size() + 1; x++) for(int y = 0; y < LINES; y++) @@ -190,7 +204,7 @@ LineChart::LineChart(Rect position, std::string title, std::map(Rect(0, 0, pos.w, pos.h)); statusBar = CGStatusBar::create(0, 0, ImagePath::builtin("radialMenu/statusBar")); - statusBar->setEnabled(false); + ((std::shared_ptr)statusBar)->setEnabled(false); // additional calculations for(auto & line : data) diff --git a/client/mainmenu/CStatisticScreen.h b/client/mainmenu/CStatisticScreen.h index 726d72f0b..8bb085c36 100644 --- a/client/mainmenu/CStatisticScreen.h +++ b/client/mainmenu/CStatisticScreen.h @@ -25,9 +25,9 @@ class CStatisticScreen : public CWindowObject OVERVIEW, CHART_RESOURCES, }; - std::map contentText = { - { OVERVIEW, "vcmi.statisticWindow.title.overview"}, - { CHART_RESOURCES, "vcmi.statisticWindow.title.resources"}, + std::map> contentInfo = { // tuple: textid, resource selection needed + { OVERVIEW, { "vcmi.statisticWindow.title.overview", false } }, + { CHART_RESOURCES, { "vcmi.statisticWindow.title.resources", true } }, }; std::shared_ptr filledBackground; diff --git a/client/widgets/GraphicalPrimitiveCanvas.cpp b/client/widgets/GraphicalPrimitiveCanvas.cpp index c37325c55..26eb3d7bd 100644 --- a/client/widgets/GraphicalPrimitiveCanvas.cpp +++ b/client/widgets/GraphicalPrimitiveCanvas.cpp @@ -64,6 +64,12 @@ void GraphicalPrimitiveCanvas::addRectangle(const Point & topLeft, const Point & primitives.push_back({color, topLeft, size, PrimitiveType::RECTANGLE}); } +void GraphicalPrimitiveCanvas::clear() +{ + primitives.clear(); + redraw(); +} + TransparentFilledRectangle::TransparentFilledRectangle(Rect position, ColorRGBA color) : GraphicalPrimitiveCanvas(position) { diff --git a/client/widgets/GraphicalPrimitiveCanvas.h b/client/widgets/GraphicalPrimitiveCanvas.h index 2cf508b94..c7e3e7d7d 100644 --- a/client/widgets/GraphicalPrimitiveCanvas.h +++ b/client/widgets/GraphicalPrimitiveCanvas.h @@ -38,6 +38,7 @@ public: void addLine(const Point & from, const Point & to, const ColorRGBA & color); void addBox(const Point & topLeft, const Point & size, const ColorRGBA & color); void addRectangle(const Point & topLeft, const Point & size, const ColorRGBA & color); + void clear(); }; class TransparentFilledRectangle : public GraphicalPrimitiveCanvas diff --git a/client/widgets/TextControls.cpp b/client/widgets/TextControls.cpp index e424251cc..c2d1f8cb0 100644 --- a/client/widgets/TextControls.cpp +++ b/client/widgets/TextControls.cpp @@ -544,7 +544,6 @@ void CGStatusBar::activate() void CGStatusBar::deactivate() { - assert(GH.statusbar().get() == this); GH.setStatusbar(nullptr); if (enteringText)