Files
Dreierpack-Manager/src/modern/ui/nation_flags.inc
T
MichaelandClaude Fable 5.2 5b9a9109f1 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>
2026-11-14 21:59:26 +01:00

52 lines
5.6 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
namespace {
// Small UI flags, sharing the muted palette of the HTML reference. Unknown
// identifiers deliberately return no image; callers retain a neutral label.
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"},
{"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;
const std::map<std::string,std::array<const char*,3>> bars{
{"de",{"#262b30","#c85a52","#d9bf65"}},{"fr",{"#5685b6","#e6ebee","#c7625b"}},
{"it",{"#679b83","#e6ebee","#c7625b"}},{"es",{"#c75b50","#e3c66b","#c75b50"}},
{"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"}},
{"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=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\"/>";
else if(code=="en"||code=="dk"||code=="se"||code=="fi"){
const auto bg=code=="dk"?"#c7625b":code=="se"?"#5685b6":"#e6ebee";
const auto cross=code=="en"?"#c7625b":code=="se"?"#e3c66b":code=="fi"?"#5685b6":"#e6ebee";
body=rect(0,0,30,20,bg)+rect(code=="en"?13:8,0,4,20,cross)+rect(0,8,30,4,cross);
}else if(code=="ch")body=rect(0,0,30,20,"#c7625b")+rect(13,4,4,12,"#e6ebee")+rect(9,8,12,4,"#e6ebee");
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>";
}
} // namespace