The stadium as a plan drawn from its blocks
Each of the eight stands is as deep as it has places and shows how far it may grow; seats take the club's colour, terraces are hatched, a roof lies over the outer rows and a stand under construction is outlined in gold. The block list shows how far each block is built. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
e22801ce0c
commit
9006b7a05d
2 files changed
+91
-5
No files matched your search
@@ -148,3 +148,26 @@ body.silver .stadium-block[disabled],body.matchday .stadium-block[disabled] {opa
|
||||
|
||||
body.midnight .stadium-summary strong.money-amount,body.silver .stadium-summary strong.money-amount,body.matchday .stadium-summary strong.money-amount {color:var(--money);}
|
||||
body .stadium-summary strong.money-amount.is-negative {color:var(--danger);}
|
||||
|
||||
/* the stadium as a plan drawn from its blocks */
|
||||
.stadium-bowl.stadium-plan,body.silver .stadium-bowl.stadium-plan,body.matchday .stadium-bowl.stadium-plan {border:2dp var(--paper-edge);border-radius:8dp;}
|
||||
.stadium-letter,body.silver .stadium-letter,body.matchday .stadium-letter {width:76dp;height:76dp;border:3dp #3d362a;border-radius:38dp;background-color:#fdfaf2;color:#3d362a;font-family:Display;font-size:44dp;font-weight:bold;decorator:none;}
|
||||
.stadium-letter:hover,body.silver .stadium-letter:hover {background-color:#ffffff;border-color:#25617a;color:#25617a;}
|
||||
.stadium-letter.building {border-color:#c9962e;color:#8a6414;opacity:1;}
|
||||
.stadium-plan-legend {position:absolute;left:24dp;bottom:16dp;height:40dp;display:flex;align-items:center;font-size:24dp;color:#3d362a;}
|
||||
body.midnight .stadium-plan-legend,body.matchday .stadium-plan-legend {color:#d5dde3;}
|
||||
.stadium-plan-legend span {display:block;flex-shrink:0;}
|
||||
.stadium-plan-legend .key {width:34dp;height:22dp;margin:0 10dp 0 26dp;border:2dp #3d362a;border-radius:3dp;}
|
||||
.stadium-plan-legend .key.seats {margin-left:0;}
|
||||
.stadium-plan-legend .key.terrace {background-color:#d8cfb9;}
|
||||
.stadium-plan-legend .key.roof {background-color:#4d5660;}
|
||||
.stadium-plan-legend .key.most {background-color:transparent;border:2dp #3d362a88;}
|
||||
.stadium-plan-legend .key.building {background-color:#c9962e40;border-color:#c9962e;}
|
||||
.stadium-plan-total {position:absolute;right:24dp;top:18dp;width:420dp;text-align:right;color:#3d362a;}
|
||||
body.midnight .stadium-plan-total,body.matchday .stadium-plan-total {color:#d5dde3;}
|
||||
.stadium-plan-total strong {display:block;font-family:Display;font-size:64dp;line-height:70dp;font-weight:bold;}
|
||||
.stadium-plan-total span {display:block;font-size:26dp;line-height:34dp;margin-bottom:8dp;}
|
||||
.stadium-block-bar {position:absolute;left:28dp;right:220dp;bottom:10dp;height:8dp;border-radius:4dp;background-color:var(--rule);overflow:hidden;display:block;}
|
||||
.stadium-block-bar span {display:block;height:8dp;border-radius:4dp;background-color:#9a7a3a;}
|
||||
.stadium-block-copy strong {font-family:Display;font-size:34dp;font-weight:bold;}
|
||||
.stadium-plan-total {right:auto;left:24dp;top:16dp;text-align:left;width:380dp;}
|
||||
@@ -32,6 +32,59 @@ std::string stadium_feedback(const Json "e,bool invalid) {
|
||||
std::string stadium_svg(const std::string &body,double w,double h) {
|
||||
return "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 "+scalar(w)+" "+scalar(h)+"\">"+body+"</svg>";
|
||||
}
|
||||
// The stadium as an architect's plan, drawn from the blocks themselves: each of the eight
|
||||
// stands is as deep as it has places, its dashed outline shows how far it may grow, seats
|
||||
// take the club's colour, terraces are hatched, a roof lies over the outer rows, and a
|
||||
// stand under construction is outlined in gold. Angles in degrees, clockwise from the east.
|
||||
constexpr std::array<std::array<double,2>,8> stadium_plan_spans{{{{205,245}},{{245,295}},{{295,335}},{{-25,25}},{{25,65}},{{65,115}},{{115,155}},{{155,205}}}};
|
||||
constexpr double stadium_plan_w=1426,stadium_plan_h=989,stadium_plan_rx=330,stadium_plan_ry=205;
|
||||
double stadium_plan_depth(int64_t places,int64_t greatest) {return 50+168.0*double(std::max<int64_t>(0,places))/double(std::max<int64_t>(1,greatest));}
|
||||
std::array<double,2> stadium_plan_point(double degrees,double depth) {
|
||||
const double a=degrees*3.14159265358979/180;
|
||||
return {stadium_plan_w/2+(stadium_plan_rx+depth)*std::cos(a),stadium_plan_h/2+(stadium_plan_ry+depth)*std::sin(a)};
|
||||
}
|
||||
std::string stadium_plan_svg(const Json &blocks,const std::string &club_colour,const std::string &theme) {
|
||||
const bool paper=theme=="silver";
|
||||
const std::string ground=paper?"#f6efdc":"#1c2630",grid=paper?"#8a7a5522":"#dfeaf514",ink=paper?"#3d362a":"#d5dde3",
|
||||
terrace=paper?"#d8cfb9":"#4a5661",roof=paper?"#4d5660":"#0f151b",gold="#c9962e";
|
||||
int64_t greatest=1;for(const auto &b:blocks)greatest=std::max(greatest,b.at("max_places").get<int64_t>());
|
||||
const auto ring=[&](double from,double to,double inner,double outer) {
|
||||
std::string d;
|
||||
for(double a=from;a<=to+.01;a+=2.5){const auto p=stadium_plan_point(a,outer);d+=(d.empty()?"M":"L")+scalar(p[0])+" "+scalar(p[1]);}
|
||||
for(double a=to;a>=from-.01;a-=2.5){const auto p=stadium_plan_point(a,inner);d+="L"+scalar(p[0])+" "+scalar(p[1]);}
|
||||
return d+"Z";
|
||||
};
|
||||
std::string body="<rect width=\""+scalar(stadium_plan_w)+"\" height=\""+scalar(stadium_plan_h)+"\" fill=\""+ground+"\"/>";
|
||||
for(double x=46;x<stadium_plan_w;x+=46)body+="<path d=\"M"+scalar(x)+" 0V"+scalar(stadium_plan_h)+"\" stroke=\""+grid+"\" stroke-width=\"2\"/>";
|
||||
for(double y=46;y<stadium_plan_h;y+=46)body+="<path d=\"M0 "+scalar(y)+"H"+scalar(stadium_plan_w)+"\" stroke=\""+grid+"\" stroke-width=\"2\"/>";
|
||||
// the pitch inside its track
|
||||
body+="<ellipse cx=\""+scalar(stadium_plan_w/2)+"\" cy=\""+scalar(stadium_plan_h/2)+"\" rx=\""+scalar(stadium_plan_rx+40)+"\" ry=\""+scalar(stadium_plan_ry+40)+"\" fill=\""+(paper?"#e7dcc0":"#27323c")+"\" stroke=\""+ink+"\" stroke-width=\"3\"/>";
|
||||
const double pw=500,ph=300,px=(stadium_plan_w-pw)/2,py=(stadium_plan_h-ph)/2;
|
||||
for(int stripe=0;stripe<10;++stripe)body+="<rect x=\""+scalar(px+stripe*pw/10)+"\" y=\""+scalar(py)+"\" width=\""+scalar(pw/10)+"\" height=\""+scalar(ph)+"\" fill=\""+(stripe%2?"#4f9a5c":"#57a765")+"\"/>";
|
||||
body+="<g fill=\"none\" stroke=\"#f4f7ef\" stroke-width=\"4\"><rect x=\""+scalar(px)+"\" y=\""+scalar(py)+"\" width=\""+scalar(pw)+"\" height=\""+scalar(ph)+"\"/><path d=\"M"+scalar(px+pw/2)+" "+scalar(py)+"V"+scalar(py+ph)+"\"/><circle cx=\""+scalar(px+pw/2)+"\" cy=\""+scalar(py+ph/2)+"\" r=\"46\"/>"
|
||||
"<rect x=\""+scalar(px)+"\" y=\""+scalar(py+ph/2-80)+"\" width=\"74\" height=\"160\"/><rect x=\""+scalar(px+pw-74)+"\" y=\""+scalar(py+ph/2-80)+"\" width=\"74\" height=\"160\"/></g>";
|
||||
for(size_t i=0;i<8&&i<blocks.size();++i) {
|
||||
const auto &b=blocks[i];const double from=stadium_plan_spans[i][0]+1.4,to=stadium_plan_spans[i][1]-1.4;
|
||||
const double inner=48,built=inner+stadium_plan_depth(b.at("display_places").get<int64_t>(),greatest),most=inner+stadium_plan_depth(b.at("max_places").get<int64_t>(),greatest);
|
||||
const bool seats=b.at("display_seats").get<bool>(),roofed=b.at("display_roof").get<bool>(),building=b.at("building").get<bool>();
|
||||
// how far the stand may grow
|
||||
body+="<path d=\""+ring(from,to,inner,most)+"\" fill=\"none\" stroke=\""+ink+"\" stroke-opacity=\".4\" stroke-width=\"3\" stroke-dasharray=\"14 10\"/>";
|
||||
body+="<path d=\""+ring(from,to,inner,built)+"\" fill=\""+(seats?club_colour:terrace)+"\" stroke=\""+ink+"\" stroke-width=\"4\" stroke-linejoin=\"round\"/>";
|
||||
// rows of seats run along the stand, the steps of a terrace across it
|
||||
if(seats)for(double depth=inner+22;depth<built-8;depth+=22){std::string d;for(double a=from+1;a<=to-1+.01;a+=2.5){const auto p=stadium_plan_point(a,depth);d+=(d.empty()?"M":"L")+scalar(p[0])+" "+scalar(p[1]);}body+="<path d=\""+d+"\" fill=\"none\" stroke=\"#ffffff\" stroke-opacity=\".42\" stroke-width=\"3\"/>";}
|
||||
else for(double a=from+4;a<to-1;a+=5){const auto p=stadium_plan_point(a,inner+6),q=stadium_plan_point(a,built-6);body+="<path d=\"M"+scalar(p[0])+" "+scalar(p[1])+"L"+scalar(q[0])+" "+scalar(q[1])+"\" stroke=\""+ink+"\" stroke-opacity=\".3\" stroke-width=\"3\"/>";}
|
||||
if(roofed) {
|
||||
const double edge=built-(built-inner)*.42;
|
||||
body+="<path d=\""+ring(from,to,edge,built+10)+"\" fill=\""+roof+"\" fill-opacity=\".9\" stroke=\""+ink+"\" stroke-width=\"4\" stroke-linejoin=\"round\"/>";
|
||||
for(double a=from+5;a<to-1;a+=10){const auto p=stadium_plan_point(a,edge),q=stadium_plan_point(a,built+10);body+="<path d=\"M"+scalar(p[0])+" "+scalar(p[1])+"L"+scalar(q[0])+" "+scalar(q[1])+"\" stroke=\"#ffffff\" stroke-opacity=\".35\" stroke-width=\"3\"/>";}
|
||||
}
|
||||
if(building) {
|
||||
const double target=inner+stadium_plan_depth(b.at("job").value("places",b.at("display_places").get<int64_t>()),greatest);
|
||||
body+="<path d=\""+ring(from,to,inner,std::max(built,target))+"\" fill=\""+gold+"\" fill-opacity=\".18\" stroke=\""+gold+"\" stroke-width=\"7\" stroke-dasharray=\"22 12\"/>";
|
||||
}
|
||||
}
|
||||
return stadium_svg(body,stadium_plan_w,stadium_plan_h);
|
||||
}
|
||||
std::string stadium_feature_svg(const std::string &kind,bool built,const std::string &theme) {
|
||||
const std::string color=theme=="silver"?"#25617a":theme=="matchday"?"#efb2aa":built?"#b7e0d1":"#a8cbbd";
|
||||
const auto path=kind=="seats"?"M7 4h16v13H7zM5 20h22v5H5zM8 25v5M24 25v5M9 9h14":"M2 16 16 4l14 12M6 15v14M26 15v14M10 17h12v12H10";
|
||||
@@ -90,19 +143,29 @@ std::string App::render_stadium() {
|
||||
if(view!="panorama")out+="<header class=\"stadium-heading\"><div class=\"stadium-heading-copy\"><h2>"+esc(overview.at("name").get<std::string>())+"</h2><p>"+(view=="inside"?"Innenansicht":"Stadiondaten")+"</p></div><div class=\"stadium-summary\"><div><span>"+(future?"Geplante Kapazität":"Verfügbare Kapazität")+std::string("</span><strong>")+number(overview.at("capacity").get<int64_t>())+" <small>Plätze</small></strong></div><div><span>"+std::string(engine_mode_?"Vereinskasse":"Ausbaubudget")+"</span><strong class=\""+std::string(engine_mode_?money_classes(overview.at("budget").get<int64_t>()):"")+"\">"+esc(stadium_cash(overview.at("budget")))+"</strong></div></div></header>";
|
||||
if(view=="inside") {
|
||||
constexpr double bowl_h=1430.0*1045/1505;
|
||||
out+="<div class=\"stadium-bowl\">"+img("art.stadium-interior-v1.png",1426,bowl_h-4,false,false,2048);
|
||||
constexpr std::array<std::array<double,2>,8> letters{{{{21,20}},{{50,11}},{{80,20}},{{91,50}},{{81,80}},{{50,84}},{{20,80}},{{9,50}}}};
|
||||
// the plan is drawn from the blocks; the manager's club gives the seats their colour
|
||||
std::string seat_colour;
|
||||
if(const auto *own=world_->find("clubs",club);own&&!own->value("crest","").empty())seat_colour=renderer_.crest_colour(own->value("crest",""));
|
||||
if(seat_colour.empty())seat_colour="#3d6f8f";
|
||||
std::string plan_key=seat_colour+theme_+(future?"f":"n");
|
||||
int64_t greatest=1,built_sum=0,most_sum=0;
|
||||
for(const auto &b:overview.at("blocks")){greatest=std::max(greatest,b.at("max_places").get<int64_t>());built_sum+=b.at("display_places").get<int64_t>();most_sum+=b.at("max_places").get<int64_t>();
|
||||
plan_key+="-"+std::to_string(b.at("display_places").get<int64_t>())+(b.at("display_seats").get<bool>()?"s":"t")+(b.at("display_roof").get<bool>()?"r":"o")+(b.at("building").get<bool>()?"b"+std::to_string(b.at("job").value("places",int64_t(0))):"");}
|
||||
out+="<div class=\"stadium-bowl stadium-plan\">"+picture(renderer_.diagram("stadium-plan-"+plan_key,stadium_plan_svg(overview.at("blocks"),seat_colour,theme_),2852),1426,bowl_h-4);
|
||||
for(size_t i=0;i<8;++i) {
|
||||
const auto &b=overview.at("blocks")[i];const bool building=b.at("building").get<bool>();
|
||||
out+=btn("stadium-block",b.at("letter").get<std::string>(),std::string("stadium-letter ")+(building?"building":""),"id=\"stadium-letter-"+std::to_string(i)+"\" data-id=\""+std::to_string(i)+"\" style=\""+rect(letters[i][0]*14.26-48,letters[i][1]*(bowl_h-4)/100-46,96,92)+"\" aria-label=\"Block "+b.at("letter").get<std::string>()+", "+esc(b.at("name").get<std::string>())+"\" "+(building?"disabled=\"disabled\"":""));
|
||||
const double depth=48+stadium_plan_depth(b.at("display_places").get<int64_t>(),greatest)/2;
|
||||
const auto at=stadium_plan_point((stadium_plan_spans[i][0]+stadium_plan_spans[i][1])/2,depth);
|
||||
out+=btn("stadium-block",b.at("letter").get<std::string>(),std::string("stadium-letter ")+(building?"building":""),"id=\"stadium-letter-"+std::to_string(i)+"\" data-id=\""+std::to_string(i)+"\" style=\""+rect(at[0]*1426/stadium_plan_w-38,at[1]*(bowl_h-4)/stadium_plan_h-38,76,76)+"\" aria-label=\"Block "+b.at("letter").get<std::string>()+", "+esc(b.at("name").get<std::string>())+"\" "+(building?"disabled=\"disabled\"":""));
|
||||
}
|
||||
out+="</div>";
|
||||
out+="<div class=\"stadium-plan-legend\"><span class=\"key seats\" style=\"background-color:"+seat_colour+";\"></span><span>Sitzplätze</span><span class=\"key terrace\"></span><span>Stehplätze</span><span class=\"key roof\"></span><span>Dach</span><span class=\"key most\"></span><span>Ausbaugrenze</span><span class=\"key building\"></span><span>Im Bau</span></div>"
|
||||
"<div class=\"stadium-plan-total\"><strong>"+number(built_sum)+"</strong><span>von "+number(most_sum)+" Plätzen ausgebaut</span><div class=\"bank-part-track\"><div style=\"width:"+scalar(most_sum>0?built_sum*100.0/most_sum:0)+"%;\"></div></div></div></div>";
|
||||
for(size_t i=0;i<8;++i) {
|
||||
const auto &b=overview.at("blocks")[i];const bool building=b.at("building").get<bool>();
|
||||
const auto &j=b.at("job");const auto detail=future?(building?"Im Bau: "+number(j.at("places").get<int64_t>())+" Plätze":"kein Bau"):number(b.at("display_places").get<int64_t>())+" Plätze";
|
||||
const auto note=future?(building?"Bauzeit: "+std::to_string(j.at("weeks").get<int>())+" Wochen":""):("max. "+number(b.at("max_places").get<int64_t>()));
|
||||
const double top=note.empty()?48.625:34.625;
|
||||
out+=btn("stadium-block","<span class=\"stadium-block-copy\" style=\"top:"+scalar(top)+"dp;\"><strong>Block "+b.at("letter").get<std::string>()+"</strong><span>"+esc(detail)+"</span><small>"+esc(note)+"</small></span><span class=\"stadium-block-icons\">"+feature("seats",b.at("display_seats").get<bool>(),76)+feature("roof",b.at("display_roof").get<bool>(),76)+"</span>","stadium-block "+std::string(building?"building":""),"id=\"stadium-block-"+std::to_string(i)+"\" data-id=\""+std::to_string(i)+"\" style=\""+rect(1822,134+i*201.25,790,189.25)+"\" "+(building?"disabled=\"disabled\"":""));
|
||||
out+=btn("stadium-block","<span class=\"stadium-block-copy\" style=\"top:"+scalar(top)+"dp;\"><strong>Block "+b.at("letter").get<std::string>()+"</strong><span>"+esc(detail)+"</span><small>"+esc(note)+"</small></span><span class=\"stadium-block-bar\"><span style=\"width:"+scalar(std::clamp(b.at("display_places").get<int64_t>()*100.0/double(std::max<int64_t>(1,b.at("max_places").get<int64_t>())),0.0,100.0))+"%;\"></span></span><span class=\"stadium-block-icons\">"+feature("seats",b.at("display_seats").get<bool>(),76)+feature("roof",b.at("display_roof").get<bool>(),76)+"</span>","stadium-block "+std::string(building?"building":""),"id=\"stadium-block-"+std::to_string(i)+"\" data-id=\""+std::to_string(i)+"\" style=\""+rect(1822,134+i*201.25,790,189.25)+"\" "+(building?"disabled=\"disabled\"":""));
|
||||
}
|
||||
for(size_t i=0;i<8;++i) {
|
||||
const auto &f=overview.at("facilities")[i];const int level=f.at("display_level").get<int>();const auto art=renderer_.image("stadium.facility."+std::to_string(i)+".level."+std::to_string(level),false,2048);const double h=art.width?391.0*art.height/art.width:215;
|
||||
|
||||
Reference in new issue
Block a user