The goal banner above its card, for every match that scores; more flags
The banner lay beneath the score board and clock and wrapped its score; it now lies above them with crest, headline and score in one row, and each match that scores in the running minute shows its own. Flags for Croatia, Senegal, Colombia, Canada, Korea, Portugal, Argentina and further nations. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
fe4b034181
commit
5b9a9109f1
3 files changed
+59
-12
No files matched your search
@@ -327,16 +327,28 @@ std::string App::live_card(const Json &match, const Json &frame, const std::stri
|
||||
}
|
||||
|
||||
// a goal that has just fallen: a banner across this card, once
|
||||
if (!frame.at("events").empty()) {
|
||||
const auto &last = frame.at("events").back();
|
||||
if (last.at("match_id") == match.at("id") && last.value("kind", std::string()) == "goal" && !live_.finished() &&
|
||||
last.at("minute").get<int>() >= minute - 1) {
|
||||
if (minute == 0) live_moment_.clear(); // a new match day: its banners are new again
|
||||
if (!frame.at("events").empty() && !live_.finished()) {
|
||||
// this match's latest report of the running minute; several matches may score at once
|
||||
const Json *goal = nullptr;
|
||||
const auto &events = frame.at("events");
|
||||
for (size_t at = events.size(); at-- > 0;) {
|
||||
const auto &event = events[at];
|
||||
if (event.at("minute").get<int>() < minute - 1) break;
|
||||
if (event.at("match_id") != match.at("id")) continue;
|
||||
if (event.value("kind", std::string()) == "goal") goal = &event;
|
||||
break;
|
||||
}
|
||||
if (goal) {
|
||||
// it stays while the minute lasts and slides in only the first time it is drawn
|
||||
const bool fresh = live_moment_ != last.at("id").get<std::string>();
|
||||
live_moment_ = last.at("id").get<std::string>();
|
||||
const size_t side = last.value("side", std::string("home")) == "away" ? 1 : 0;
|
||||
out += "<div class=\"live-moment" + std::string(fresh ? " fresh" : "") + "\" style=\"background-color:" + colours[side] + ";\">" + live_badge(match.at(side ? "away" : "home"), quad ? 120 : 200) +
|
||||
"<div><strong>TOR!</strong>" + live_text(last.value("body", std::string()), "live-moment-text") + "</div>" + live_text(live_score_text(last.at("score")), "live-moment-score") + "</div>";
|
||||
const auto mark = "|" + goal->at("id").get<std::string>() + "|";
|
||||
const bool fresh = live_moment_.find(mark) == std::string::npos;
|
||||
if (fresh) live_moment_ += mark;
|
||||
const size_t side = goal->value("side", std::string("home")) == "away" ? 1 : 0;
|
||||
out += "<div class=\"live-moment" + std::string(fresh ? " fresh" : "") + "\" style=\"background-color:" + colours[side] + ";\">" +
|
||||
live_badge(match.at(side ? "away" : "home"), layout == "solo" ? 200 : quad ? 96 : 150) +
|
||||
"<div class=\"live-moment-copy\"><strong>TOR!</strong>" + live_text(goal->value("headline", std::string()), "live-moment-text") + "</div>" +
|
||||
live_text(live_score_text(goal->at("score")), "live-moment-score") + "</div>";
|
||||
}
|
||||
}
|
||||
return out + "</button>";
|
||||
|
||||
@@ -5,7 +5,9 @@ namespace {
|
||||
std::string ui_nation_flag_svg(const std::string &value) {
|
||||
std::string code=value.starts_with("nation:")?value.substr(7):value;
|
||||
for(auto &c:code)if(c>='A'&&c<='Z')c=char(c-'A'+'a');
|
||||
const std::map<std::string,std::string> aliases{{"x-eng","en"},{"eng","en"},{"ger","de"},{"deu","de"},{"fra","fr"},{"ita","it"},{"esp","es"},{"ned","nl"},{"nld","nl"},{"jpn","jp"},{"swe","se"},{"den","dk"},{"dnk","dk"},{"nga","ng"},{"bra","br"},{"mar","ma"},{"alg","dz"},{"dza","dz"}};
|
||||
const std::map<std::string,std::string> aliases{{"x-eng","en"},{"eng","en"},{"ger","de"},{"deu","de"},{"fra","fr"},{"ita","it"},{"esp","es"},{"ned","nl"},{"nld","nl"},{"jpn","jp"},{"swe","se"},{"den","dk"},{"dnk","dk"},{"nga","ng"},{"bra","br"},{"mar","ma"},{"alg","dz"},{"dza","dz"},
|
||||
{"cro","hr"},{"hrv","hr"},{"sen","sn"},{"col","co"},{"can","ca"},{"kor","kr"},{"por","pt"},{"prt","pt"},{"arg","ar"},{"srb","rs"},{"bul","bg"},{"bgr","bg"},
|
||||
{"civ","ci"},{"cmr","cm"},{"mli","ml"},{"gha","gh"},{"mex","mx"},{"per","pe"},{"cze","cz"},{"tur","tr"},{"ecu","ec"},{"lux","lu"},{"gui","gn"},{"gin","gn"}};
|
||||
if(auto it=aliases.find(code);it!=aliases.end())code=it->second;
|
||||
const auto rect=[](double x,double y,double w,double h,const char*fill){return "<rect x=\""+scalar(x)+"\" y=\""+scalar(y)+"\" width=\""+scalar(w)+"\" height=\""+scalar(h)+"\" fill=\""+fill+"\"/>";};
|
||||
std::string body;
|
||||
@@ -15,9 +17,17 @@ std::string ui_nation_flag_svg(const std::string &value) {
|
||||
{"nl",{"#bf5c56","#e6ebee","#5b83b1"}},{"be",{"#262b30","#e3c66b","#c7625b"}},
|
||||
{"ie",{"#679b83","#e6ebee","#d69455"}},{"ro",{"#5685b6","#e3c66b","#c7625b"}},
|
||||
{"ng",{"#38865d","#e6ebee","#38865d"}},{"at",{"#c7625b","#e6ebee","#c7625b"}},
|
||||
{"ru",{"#e6ebee","#5685b6","#c7625b"}},{"hu",{"#c7625b","#e6ebee","#679b83"}}};
|
||||
{"ru",{"#e6ebee","#5685b6","#c7625b"}},{"hu",{"#c7625b","#e6ebee","#679b83"}},
|
||||
{"hr",{"#c7625b","#e6ebee","#5685b6"}},{"rs",{"#c7625b","#5685b6","#e6ebee"}},
|
||||
{"bg",{"#e6ebee","#679b83","#c7625b"}},{"lu",{"#c7625b","#e6ebee","#7fb0d6"}},
|
||||
{"ar",{"#7fb0d6","#e6ebee","#7fb0d6"}},{"gh",{"#c7625b","#e3c66b","#38865d"}},
|
||||
{"sn",{"#38865d","#e3c66b","#c7625b"}},{"ml",{"#38865d","#e3c66b","#c7625b"}},
|
||||
{"cm",{"#38865d","#c7625b","#e3c66b"}},{"gn",{"#c7625b","#e3c66b","#38865d"}},
|
||||
{"ci",{"#d69455","#e6ebee","#38865d"}},{"mx",{"#38865d","#e6ebee","#c7625b"}},
|
||||
{"pe",{"#c7625b","#e6ebee","#c7625b"}}};
|
||||
static const std::set<std::string> upright{"fr","it","be","ie","ro","ng","sn","ml","cm","gn","ci","mx","pe"};
|
||||
if(auto it=bars.find(code);it!=bars.end()){
|
||||
const bool vertical=code=="fr"||code=="it"||code=="be"||code=="ie"||code=="ro"||code=="ng";
|
||||
const bool vertical=upright.contains(code);
|
||||
for(int i=0;i<3;++i)body+=rect(vertical?i*10.:0,vertical?0:i*20./3,vertical?10:30,vertical?20:20./3,it->second[size_t(i)]);
|
||||
}else if(code=="pl"||code=="ua")body=rect(0,0,30,10,code=="pl"?"#e6ebee":"#5685b6")+rect(0,10,30,10,code=="pl"?"#c7625b":"#e3c66b");
|
||||
else if(code=="jp")body=rect(0,0,30,20,"#e6ebee")+"<circle cx=\"15\" cy=\"10\" r=\"6\" fill=\"#c7625b\"/>";
|
||||
@@ -29,6 +39,12 @@ std::string ui_nation_flag_svg(const std::string &value) {
|
||||
else if(code=="ma")body=rect(0,0,30,20,"#c7625b")+"<path d=\"M15 4L18.5 15L9.3 8.2H20.7L11.5 15Z\" fill=\"none\" stroke=\"#266747\" stroke-width=\"1\"/>";
|
||||
else if(code=="dz")body=rect(0,0,15,20,"#38865d")+rect(15,0,15,20,"#e6ebee")+"<defs><mask id=\"crescent\"><rect width=\"30\" height=\"20\" fill=\"white\"/><circle cx=\"17\" cy=\"10\" r=\"5\" fill=\"black\"/></mask></defs><circle cx=\"15\" cy=\"10\" r=\"6\" fill=\"#c7625b\" mask=\"url(#crescent)\"/><path d=\"M18 7L18.7 9.1L21 9.1L19.2 10.5L19.9 12.7L18 11.3L16.1 12.7L16.8 10.5L15 9.1H17.3Z\" fill=\"#c7625b\"/>";
|
||||
else if(code=="br")body=rect(0,0,30,20,"#38865d")+"<path d=\"M15 1.6L28 10L15 18.4L2 10Z\" fill=\"#e3c66b\"/><circle cx=\"15\" cy=\"10\" r=\"5.5\" fill=\"#40658d\"/><path d=\"M10 8Q15 6.5 20 11\" stroke=\"#e6ebee\" stroke-width=\"1\" fill=\"none\"/><g fill=\"#e6ebee\"><circle cx=\"12\" cy=\"11\" r=\".3\"/><circle cx=\"15\" cy=\"13\" r=\".3\"/><circle cx=\"18\" cy=\"12\" r=\".3\"/><circle cx=\"14\" cy=\"10\" r=\".3\"/></g>";
|
||||
else if(code=="co"||code=="ec")body=rect(0,0,30,10,"#e3c66b")+rect(0,10,30,5,"#5685b6")+rect(0,15,30,5,"#c7625b");
|
||||
else if(code=="ca")body=rect(0,0,30,20,"#e6ebee")+rect(0,0,7.5,20,"#c7625b")+rect(22.5,0,7.5,20,"#c7625b")+"<path d=\"M15 4.5L16.3 7.6L18.6 6.8L17.8 10.2L20.2 10.6L17.4 13H15.6V15.6H14.4V13H12.6L9.8 10.6L12.2 10.2L11.4 6.8L13.7 7.6Z\" fill=\"#c7625b\"/>";
|
||||
else if(code=="kr")body=rect(0,0,30,20,"#e6ebee")+"<path d=\"M10 10A5 5 0 0 1 20 10Z\" fill=\"#c7625b\"/><path d=\"M10 10A5 5 0 0 0 20 10Z\" fill=\"#5685b6\"/>";
|
||||
else if(code=="pt")body=rect(0,0,12,20,"#38865d")+rect(12,0,18,20,"#c7625b")+"<circle cx=\"12\" cy=\"10\" r=\"3.4\" fill=\"#e3c66b\"/>";
|
||||
else if(code=="cz")body=rect(0,0,30,10,"#e6ebee")+rect(0,10,30,10,"#c7625b")+"<path d=\"M0 0L13 10L0 20Z\" fill=\"#5685b6\"/>";
|
||||
else if(code=="tr")body=rect(0,0,30,20,"#c7625b")+"<defs><mask id=\"moon\"><rect width=\"30\" height=\"20\" fill=\"white\"/><circle cx=\"13\" cy=\"10\" r=\"4\" fill=\"black\"/></mask></defs><circle cx=\"11.5\" cy=\"10\" r=\"5\" fill=\"#e6ebee\" mask=\"url(#moon)\"/><circle cx=\"18\" cy=\"10\" r=\"1.4\" fill=\"#e6ebee\"/>";
|
||||
else return {};
|
||||
return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"30\" height=\"20\" viewBox=\"0 0 30 20\">"+body+"</svg>";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user