mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
table fill
This commit is contained in:
parent
504aec3b52
commit
4b042aa153
@ -180,6 +180,7 @@
|
||||
"vcmi.statisticWindow.title.resourcesSpentArmy" : "army costs",
|
||||
"vcmi.statisticWindow.title.resourcesSpentBuildings" : "building costs",
|
||||
"vcmi.statisticWindow.title.mapExplored" : "map explored ratio",
|
||||
"vcmi.statisticWindow.param.daysSurvived" : "Days survived",
|
||||
|
||||
"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.",
|
||||
|
@ -180,6 +180,7 @@
|
||||
"vcmi.statisticWindow.title.resourcesSpentArmy" : "Armeekosten",
|
||||
"vcmi.statisticWindow.title.resourcesSpentBuildings" : "Gebäudekosten",
|
||||
"vcmi.statisticWindow.title.mapExplored" : "Maperkundungsrate",
|
||||
"vcmi.statisticWindow.param.daysSurvived" : "Tage überlebt",
|
||||
|
||||
"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.",
|
||||
|
@ -209,17 +209,31 @@ OverviewPanel::OverviewPanel(Rect position, std::string title, StatisticDataSet
|
||||
|
||||
layout.push_back(std::make_shared<CLabel>(pos.w / 2, 10, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, title));
|
||||
|
||||
int yOffs = 30;
|
||||
canvas = std::make_shared<GraphicalPrimitiveCanvas>(Rect(0, Y_OFFS, pos.w - 16, pos.h - Y_OFFS));
|
||||
|
||||
canvas = std::make_shared<GraphicalPrimitiveCanvas>(Rect(0, yOffs, pos.w - 16, pos.h - yOffs));
|
||||
auto playerDataFilter = [data](PlayerColor color){
|
||||
std::vector<StatisticDataSetEntry> tmpData;
|
||||
std::copy_if(data.data.begin(), data.data.end(), std::back_inserter(tmpData), [color](StatisticDataSetEntry e){return e.player == color;} );
|
||||
return tmpData;
|
||||
};
|
||||
|
||||
int usedLines = 100;
|
||||
dataExtract = {
|
||||
{
|
||||
CGI->generaltexth->translate("vcmi.statisticWindow.param.daysSurvived1"), [playerDataFilter](PlayerColor color){
|
||||
return playerDataFilter(color).size() ? std::to_string(playerDataFilter(color).size()) : "";
|
||||
}
|
||||
},
|
||||
|
||||
slider = std::make_shared<CSlider>(Point(pos.w - 16, yOffs), pos.h - yOffs, [this](int to){ update(); setRedrawParent(true); redraw(); }, LINES, usedLines, 0, Orientation::VERTICAL, CSlider::BLUE);
|
||||
//kill dead ratio (numBattles / numWinBattles)
|
||||
};
|
||||
|
||||
int usedLines = dataExtract.size();
|
||||
|
||||
slider = std::make_shared<CSlider>(Point(pos.w - 16, Y_OFFS), pos.h - Y_OFFS, [this](int to){ update(to); setRedrawParent(true); redraw(); }, LINES - 1, usedLines, 0, Orientation::VERTICAL, CSlider::BLUE);
|
||||
slider->setPanningStep(canvas->pos.h / LINES);
|
||||
slider->setScrollBounds(Rect(-pos.w + slider->pos.w, 0, pos.w, canvas->pos.h));
|
||||
|
||||
Point fieldSize(canvas->pos.w / (graphics->playerColors.size() + 2), canvas->pos.h / LINES);
|
||||
fieldSize = Point(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++)
|
||||
{
|
||||
@ -230,15 +244,28 @@ OverviewPanel::OverviewPanel(Rect position, std::string title, StatisticDataSet
|
||||
canvas->addRectangle(Point(xStart, yStart), Point(x == 0 ? 2 * fieldSize.x : fieldSize.x, fieldSize.y), ColorRGBA(127, 127, 127, 255));
|
||||
}
|
||||
|
||||
update();
|
||||
update(0);
|
||||
}
|
||||
|
||||
void OverviewPanel::update()
|
||||
void OverviewPanel::update(int to)
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
|
||||
content.clear();
|
||||
content.push_back(std::make_shared<CLabel>(pos.w / 2, 100, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, "blah" + vstd::getDateTimeISO8601Basic(std::time(0))));
|
||||
for(int y = to; y < LINES - 1 + to; y++)
|
||||
{
|
||||
if(y >= dataExtract.size())
|
||||
continue;
|
||||
|
||||
for(int x = 0; x < PlayerColor::PLAYER_LIMIT_I + 1; x++)
|
||||
{
|
||||
if(y == to)
|
||||
content.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("ITGFLAGS"), x, 0, 180 + x * fieldSize.x, 35));
|
||||
int xStart = (x + (x == 0 ? 0 : 1)) * fieldSize.x + (x == 0 ? fieldSize.x : (fieldSize.x / 2));
|
||||
int yStart = Y_OFFS + (y + 1 - to) * fieldSize.y + (fieldSize.y / 2);
|
||||
content.push_back(std::make_shared<CLabel>(xStart, yStart, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, (x == 0 ? dataExtract[y].first : dataExtract[y].second(PlayerColor(x - 1))), x == 0 ? (fieldSize.x * 2) : fieldSize.x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LineChart::LineChart(Rect position, std::string title, std::map<ColorRGBA, std::vector<float>> data, float maxY)
|
||||
|
@ -89,9 +89,14 @@ class OverviewPanel : public CIntObject
|
||||
std::vector<std::shared_ptr<CIntObject>> content;
|
||||
std::shared_ptr<CSlider> slider;
|
||||
|
||||
const int LINES = 15;
|
||||
Point fieldSize;
|
||||
|
||||
void update();
|
||||
std::vector<std::pair<std::string, std::function<std::string(PlayerColor color)>>> dataExtract;
|
||||
|
||||
const int LINES = 15;
|
||||
const int Y_OFFS = 30;
|
||||
|
||||
void update(int to);
|
||||
public:
|
||||
OverviewPanel(Rect position, std::string title, StatisticDataSet data);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user