From 9006b7a05d3cd361b866718ff447f4c0404561a0 Mon Sep 17 00:00:00 2001 From: Weyoune Date: Sat, 14 Nov 2026 22:59:59 +0100 Subject: [PATCH] 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 --- assets/modern/stadium.rcss | 23 ++++++++++ src/modern/ui/stadium_screens.inc | 73 ++++++++++++++++++++++++++++--- 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/assets/modern/stadium.rcss b/assets/modern/stadium.rcss index e144bbe..2bcec14 100644 --- a/assets/modern/stadium.rcss +++ b/assets/modern/stadium.rcss @@ -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;} diff --git a/src/modern/ui/stadium_screens.inc b/src/modern/ui/stadium_screens.inc index 8aa42b8..a60c34c 100644 --- a/src/modern/ui/stadium_screens.inc +++ b/src/modern/ui/stadium_screens.inc @@ -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 ""+body+""; } +// 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,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(0,places))/double(std::max(1,greatest));} +std::array 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()); + 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=""; + for(double x=46;x"; + for(double y=46;y"; + // the pitch inside its track + body+=""; + 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+=""; + body+="" + ""; + for(size_t i=0;i<8&&i(),greatest),most=inner+stadium_plan_depth(b.at("max_places").get(),greatest); + const bool seats=b.at("display_seats").get(),roofed=b.at("display_roof").get(),building=b.at("building").get(); + // how far the stand may grow + body+=""; + body+=""; + // rows of seats run along the stand, the steps of a terrace across it + if(seats)for(double depth=inner+22;depth";} + else for(double a=from+4;a";} + if(roofed) { + const double edge=built-(built-inner)*.42; + body+=""; + for(double a=from+5;a";} + } + if(building) { + const double target=inner+stadium_plan_depth(b.at("job").value("places",b.at("display_places").get()),greatest); + body+=""; + } + } + 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+="

"+esc(overview.at("name").get())+"

"+(view=="inside"?"Innenansicht":"Stadiondaten")+"

"+(future?"Geplante Kapazität":"Verfügbare Kapazität")+std::string("")+number(overview.at("capacity").get())+" Plätze
"+std::string(engine_mode_?"Vereinskasse":"Ausbaubudget")+"()):"")+"\">"+esc(stadium_cash(overview.at("budget")))+"
"; if(view=="inside") { constexpr double bowl_h=1430.0*1045/1505; - out+="
"+img("art.stadium-interior-v1.png",1426,bowl_h-4,false,false,2048); - constexpr std::array,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());built_sum+=b.at("display_places").get();most_sum+=b.at("max_places").get(); + plan_key+="-"+std::to_string(b.at("display_places").get())+(b.at("display_seats").get()?"s":"t")+(b.at("display_roof").get()?"r":"o")+(b.at("building").get()?"b"+std::to_string(b.at("job").value("places",int64_t(0))):"");} + out+="
"+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(); - out+=btn("stadium-block",b.at("letter").get(),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()+", "+esc(b.at("name").get())+"\" "+(building?"disabled=\"disabled\"":"")); + const double depth=48+stadium_plan_depth(b.at("display_places").get(),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("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()+", "+esc(b.at("name").get())+"\" "+(building?"disabled=\"disabled\"":"")); } - out+="
"; + out+="
SitzplätzeStehplätzeDachAusbaugrenzeIm Bau
" + "
"+number(built_sum)+"von "+number(most_sum)+" Plätzen ausgebaut
0?built_sum*100.0/most_sum:0)+"%;\">
"; for(size_t i=0;i<8;++i) { const auto &b=overview.at("blocks")[i];const bool building=b.at("building").get(); const auto &j=b.at("job");const auto detail=future?(building?"Im Bau: "+number(j.at("places").get())+" Plätze":"kein Bau"):number(b.at("display_places").get())+" Plätze"; const auto note=future?(building?"Bauzeit: "+std::to_string(j.at("weeks").get())+" Wochen":""):("max. "+number(b.at("max_places").get())); const double top=note.empty()?48.625:34.625; - out+=btn("stadium-block","Block "+b.at("letter").get()+""+esc(detail)+""+esc(note)+""+feature("seats",b.at("display_seats").get(),76)+feature("roof",b.at("display_roof").get(),76)+"","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","Block "+b.at("letter").get()+""+esc(detail)+""+esc(note)+"()*100.0/double(std::max(1,b.at("max_places").get())),0.0,100.0))+"%;\">"+feature("seats",b.at("display_seats").get(),76)+feature("roof",b.at("display_roof").get(),76)+"","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();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;