Render Gold post-match pages from held read-only review data (by Codex)

This commit is contained in:
Codex authored and Codex committed 2026-10-27 09:12:36 +01:00
1 parent 86f248bbd5
commit 3f1a44b320
13 files changed
+1392 -13

No files matched your search

+18 -1
View File
@@ -2,6 +2,7 @@
// Exercise the production control builder and stylesheet with synthetic labels.
#include "modern/ui/controls.hpp"
#include "modern/ui/script_locator.hpp"
#include "modern/ui/postmatch_eleven_markup.hpp"
#include <RmlUi/Core/ElementText.h>
#include <RmlUi/Core/Elements/ElementFormControlSelect.h>
#include <RmlUi/Core/FontEngineInterface.h>
@@ -153,6 +154,22 @@ void script_locator_cases(Rml::Context &context, float density) {
context.Update();
}
}
void postmatch_eleven_cases(Rml::Context &context,const std::string &css,const char *theme) {
const auto fixture=std::filesystem::path(__FILE__).parent_path()/"fixtures/modern_post_match_eleven.json";
std::ifstream file(fixture);require(bool(file),"Synthetic supplied eleven fixture missing");
const auto data=Json::parse(file).at("eleven");
const PostmatchBadge badge=[](const Json &,double size){return "<span style='width:"+std::to_string(size)+"dp;height:"+std::to_string(size)+"dp;'>B</span>";};
const auto markup=postmatch_eleven_markup(data,badge,"<div class='image-frame'></div>");
auto *doc=context.LoadDocumentFromMemory("<rml><head><style>"+css+"</style></head><body class='"+theme+"'><section class='postmatch' style='width:2612dp;height:1460dp;'>"+markup+"</section></body></rml>");
require(doc,"Supplied eleven document missing");doc->Show();context.Update();context.Render();fit_postmatch_pitch(*doc);context.Update();context.Render();
Rml::ElementList field,list;doc->QuerySelectorAll(field,".postmatch-field-player");doc->QuerySelectorAll(list,".postmatch-nominee-name");require(field.size()==11&&list.size()==11,"Supplied eleven must render eleven field and list controls");
auto *pitch=doc->GetElementById("postmatch-pitch-surface");const auto bounds=pitch->GetBox().GetSize(Rml::BoxArea::Content);require(std::abs(bounds.x/bounds.y-740.f/1110.f)<.003f,"Supplied eleven field aspect changed");
for(size_t i=0;i<field.size();++i){require(bool(script_click_point(context,*field[i])),"Nominee field control is clipped/occluded");require(visible_text_lines(*list[i])>0,"Nominee full name lost its text");}
doc->Close();context.Update();
const auto detail=postmatch_nominee_detail(data.at("rows")[0],badge);
auto *dialog=context.LoadDocumentFromMemory("<rml><head><style>"+css+"</style></head><body class='"+theme+"'><div class='entry-dialog postmatch-dialog' style='position:absolute;left:100dp;top:100dp;'>"+detail+"</div></body></rml>");
require(dialog,"Nominee detail missing");dialog->Show();context.Update();context.Render();Rml::ElementList facts;dialog->QuerySelectorAll(facts,"dd");require(facts.size()==2&&visible_text_lines(*facts[0])>0&&visible_text_lines(*facts[1])>0,"Nominee position/unknown rating must render");dialog->Close();context.Update();
}
} // namespace
int main(int argc, char **argv) try {
require(argc == 2, "Pass the Modern asset directory");
@@ -177,7 +194,7 @@ int main(int argc, char **argv) try {
std::ostringstream css;
for (const auto *name : {"theme.rcss", "ticket.rcss", "sports.rcss",
"calendar.rcss", "reports.rcss", "report_details.rcss",
"report_pickers.rcss", "indoor.rcss", "planning.rcss", "almanac.rcss", "finance.rcss", "bank.rcss", "contracts.rcss", "amount.rcss", "environment.rcss", "advertising.rcss", "toto.rcss", "lineup.rcss", "transfer.rcss", "career_reports.rcss", "rankings.rcss", "stadium.rcss", "statistics.rcss", "news.rcss", "settings.rcss", "widgets.rcss", "files.rcss", "front.rcss"}) {
"report_pickers.rcss", "indoor.rcss", "planning.rcss", "almanac.rcss", "finance.rcss", "bank.rcss", "contracts.rcss", "amount.rcss", "environment.rcss", "advertising.rcss", "toto.rcss", "lineup.rcss", "transfer.rcss", "career_reports.rcss", "rankings.rcss", "stadium.rcss", "statistics.rcss", "news.rcss", "settings.rcss", "widgets.rcss", "files.rcss", "front.rcss", "postmatch.rcss"}) {
std::ifstream input(root / name);
require(bool(input), "Production stylesheet missing");
css << input.rdbuf() << '\n';