The stadium and its surroundings as two fixed views; the surroundings in detail
The camera no longer flies: the stadium view shows stands and facilities, the surroundings view the fourteen objects of the periphery, each in a shape of its own (road, bus stop, tram and station by level; parking lots with bays and cars; shopping centre, arcade, club house, restaurant, snack bars, fan shops in the club's colour). A part is chosen in the picture or from a list and shown on a card that leads to the builder's offer. The painted panorama is no longer used. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
20e7497f67
commit
6e3475493f
5 files changed
+274
-98
No files matched your search
@@ -203,3 +203,19 @@ body.midnight .stadium-plan-total,body.matchday .stadium-plan-total {color:#d5dd
|
||||
.stadium-model-hit:focus-visible {border-color:transparent;background-color:transparent;}
|
||||
.stadium-model-tag.letter>span {left:-30dp;top:-30dp;width:60dp;height:60dp;line-height:54dp;}
|
||||
.stadium-model-tag>span {font-size:28dp;font-weight:bold;}
|
||||
|
||||
/* names on the model stand on a framed field; the list of the surroundings */
|
||||
.stadium-model-tag>span {left:-170dp;top:-22dp;width:340dp;height:44dp;line-height:44dp;font-size:30dp;font-weight:bold;color:#3d362a;font-effect:outline(3dp #fffbf2);}
|
||||
.stadium-model-tag.chosen>span {color:#25617a;}
|
||||
.stadium-model-tag.letter>span {font-effect:none;}
|
||||
.stadium-list {padding:28dp 32dp;}
|
||||
.stadium-list h3 {margin-bottom:10dp;}
|
||||
.stadium-row {display:flex;align-items:center;width:100%;height:98dp;padding:0 16dp;border:0dp;border-bottom:2dp var(--rule);border-radius:0dp;background-color:transparent;decorator:none;font-size:36dp;text-align:left;}
|
||||
.stadium-row:hover {background-color:var(--hover);}
|
||||
.stadium-row span {display:block;flex-shrink:0;}
|
||||
.stadium-row .name {flex:1;}
|
||||
.stadium-row .job {margin-right:20dp;font-size:28dp;color:#8a6414;}
|
||||
.stadium-row-pips {display:flex;gap:8dp;}
|
||||
.stadium-row-pips .pip {width:30dp;height:30dp;border:3dp var(--rule);border-radius:6dp;}
|
||||
.stadium-row-pips .pip.on {background-color:#9a7a3a;border-color:#9a7a3a;}
|
||||
.stadium-row .stadium-row-pips {display:flex;}
|
||||
@@ -29,19 +29,12 @@ void App::sync_stadium_draft() {
|
||||
// only the picture is drawn anew; reduced motion jumps.
|
||||
bool App::stadium_focus_action(const std::string &action,Rml::Element *target) {
|
||||
if(action!="stadium-focus"||!target)return false;
|
||||
if(stadium_flying_)return true;
|
||||
// the camera stands still: a click only chooses the part (the screen drops a part that
|
||||
// does not belong to its view)
|
||||
const auto next=std::string(target->GetAttribute<Rml::String>("data-id",""));
|
||||
if(next==stadium_focus_)return true;
|
||||
stadium_view_defaults(stadium_view_);
|
||||
const auto overview=stadium_overview(stadium_view_.at("future").get<bool>());
|
||||
if(!overview.value("ok",false))return true;
|
||||
const auto scene=stadium3d::build(overview,"#3d6f8f",theme_=="silver");
|
||||
if(!next.empty()&&next!="stadium"&&!scene.centres.contains(next))return true;
|
||||
stadium_camera_from_=stadium_camera_;stadium_camera_to_=stadium3d::camera_for(scene,next);
|
||||
stadium_flying_=false;
|
||||
stadium_focus_=next;
|
||||
const bool calm=ui_preferences_.is_object()&&ui_preferences_.contains("display")&&ui_preferences_.at("display").value("motion","full")=="reduced";
|
||||
stadium_flying_=!calm&&config_.commands.empty();
|
||||
stadium_flight_start_=SDL_GetTicks64();
|
||||
focus_after_render_=next.find(':')!=std::string::npos?"stadium-card-build":"";
|
||||
refresh();
|
||||
return true;
|
||||
|
||||
+194
-16
@@ -84,7 +84,7 @@ inline void box(Scene &scene, const std::string &part, double x, double y, doubl
|
||||
}
|
||||
|
||||
// Builds the model. `seats` is the club's colour; `paper` selects the light skin's tones.
|
||||
inline Scene build(const Json &overview, const std::string &seats, bool paper) {
|
||||
inline Scene build(const Json &overview, const std::string &seats, bool paper, int mode = 0) {
|
||||
Scene scene;
|
||||
scene.ink = paper ? "#3d362a" : "#d5dde3";
|
||||
scene.accent = paper ? "#25617a" : "#9ac7d8";
|
||||
@@ -93,7 +93,9 @@ inline Scene build(const Json &overview, const std::string &seats, bool paper) {
|
||||
const auto level_of = [](const Json &row) { return row.value("display_level", row.value("level", 0)); };
|
||||
const auto building = [](const Json &row) { return row.value("building", false); };
|
||||
// the plate everything stands on
|
||||
scene.faces.push_back({{{-350, -262, 0}, {350, -262, 0}, {350, 262, 0}, {-350, 262, 0}}, plate, "", false, false, true, 3, 1, "", {}, -1000});
|
||||
// inside, the plate runs beyond the picture; around, it is the plot with its edge
|
||||
const double px = mode == 1 ? 345 : 900, py = mode == 1 ? 268 : 900;
|
||||
scene.faces.push_back({{{-px, -py, 0}, {px, -py, 0}, {px, py, 0}, {-px, py, 0}}, plate, "", false, false, true, 3, 1, "", {}, -1000});
|
||||
// the pitch: its colour tells the state of the turf (facility 4)
|
||||
const auto &facilities = overview.value("facilities", Json::array());
|
||||
const auto facility = [&](size_t index) -> const Json & { static const Json none = Json::object(); return index < facilities.size() ? facilities[index] : none; };
|
||||
@@ -214,8 +216,9 @@ inline Scene build(const Json &overview, const std::string &seats, bool paper) {
|
||||
scene.centres["facility:3"] = {at.x, at.y, 8};
|
||||
}
|
||||
// facilities 2, 5, 6, 7 as small houses beside the ground: boiler, kiosks, workshop, gate
|
||||
const std::array<std::tuple<size_t, double, double, const char *>, 4> houses{{{2, -150, -150, "#c8a58a"}, {5, 150, -150, "#d9c38a"}, {6, -150, 150, "#b9b3a2"}, {7, 150, 150, "#a9b7a0"}}};
|
||||
const std::array<std::tuple<size_t, double, double, const char *>, 4> houses{{{2, -160, -66, "#c8a58a"}, {5, 140, -92, "#d9c38a"}, {6, -148, 72, "#b9b3a2"}, {7, 160, 82, "#a9b7a0"}}};
|
||||
for (const auto &[index, x, y, colour] : houses) {
|
||||
if (mode == 1) break;
|
||||
if (index >= facilities.size()) continue;
|
||||
const std::string part = "facility:" + std::to_string(index);
|
||||
const int level = level_of(facility(index)) - (index == 2 || index == 5 ? 1 : 0);
|
||||
@@ -224,20 +227,192 @@ inline Scene build(const Json &overview, const std::string &seats, bool paper) {
|
||||
for (int n = 0; n < std::min(level, 4); ++n) box(scene, part, x + (n - (std::min(level, 4) - 1) / 2.0) * 20, y, 16, 16, 7 + 2 * level, colour);
|
||||
scene.centres[part] = {x, y, 6};
|
||||
}
|
||||
// the periphery on an outer ring: a house per object, growing with its level
|
||||
const auto &periphery = overview.value("periphery", Json::array());
|
||||
for (size_t i = 0; i < periphery.size(); ++i) {
|
||||
const std::string part = "periphery:" + std::to_string(i);
|
||||
const double a = (360.0 * double(i) / double(std::max<size_t>(1, periphery.size())) + 20) * 3.14159265358979 / 180;
|
||||
const double x = 292 * std::cos(a), y = 214 * std::sin(a);
|
||||
const int level = periphery[i].value("level", 0);
|
||||
static constexpr std::array<const char *, 6> tones{"#c9b48c", "#b7c4a8", "#c8a79a", "#a9bccb", "#d2c08f", "#bfb2c4"};
|
||||
if (level <= 0) box(scene, part, x, y, 44, 30, 1, wall, true);
|
||||
else {
|
||||
box(scene, part, x, y, 30 + 6 * level, 22 + 3 * level, 6 + 5 * level, tones[i % tones.size()]);
|
||||
if (building(periphery[i])) box(scene, part, x, y, 40 + 6 * level, 30 + 3 * level, 1, gold, true);
|
||||
// The surroundings (mode 1): every object in its own shape and at its own place, drawn at
|
||||
// its level. Level 0 is a dashed footprint, a level being built a dashed frame in gold.
|
||||
if (mode == 1) {
|
||||
// the ground itself is scenery here
|
||||
for (auto &face : scene.faces) face.part.clear();
|
||||
scene.centres.clear();
|
||||
scene.anchors.clear();
|
||||
const std::string asphalt = paper ? "#b9b2a4" : "#3c444c", brick = "#c9a58c", plaster = "#efe6cf", tile = "#a8574f", slate = paper ? "#6b747d" : "#20272e",
|
||||
wood = "#b98d5a", green = "#7fa86b", white = "#f7f4ea";
|
||||
const auto &periphery = overview.value("periphery", Json::array());
|
||||
const auto flat = [&](const std::string &part, double x, double y, double w, double d, const std::string &fill, double bias = -500) {
|
||||
scene.faces.push_back({{{x - w / 2, y - d / 2, 0.2}, {x + w / 2, y - d / 2, 0.2}, {x + w / 2, y + d / 2, 0.2}, {x - w / 2, y + d / 2, 0.2}}, fill, part, false, false, true, 2, 1, "", {}, bias});
|
||||
};
|
||||
const auto stripe = [&](double x0, double y0, double x1, double y1, const std::string &ink, bool dashed = false) {
|
||||
scene.faces.push_back({{{x0, y0, 0.3}, {x1, y1, 0.3}}, "", "", dashed, true, true, 2.2, 1, ink, {}, -450});
|
||||
};
|
||||
// a house with a pitched roof; the ridge runs along x
|
||||
const auto gabled = [&](const std::string &part, double x, double y, double w, double d, double h, double rise, const std::string &walls, const std::string &roofing) {
|
||||
box(scene, part, x, y, w, d, h, walls);
|
||||
const Vec a{x - w / 2, y - d / 2, h}, b{x + w / 2, y - d / 2, h}, c{x + w / 2, y + d / 2, h}, e{x - w / 2, y + d / 2, h}, r0{x - w / 2, y, h + rise}, r1{x + w / 2, y, h + rise};
|
||||
scene.faces.push_back({{a, b, r1, r0}, roofing, part, false, false, false, 2, 1, "", {}, 3});
|
||||
scene.faces.push_back({{e, c, r1, r0}, roofing, part, false, false, false, 2, 1, "", {}, 3});
|
||||
scene.faces.push_back({{a, e, r0}, walls, part, false, false, false, 2, 1, "", {}, 3});
|
||||
scene.faces.push_back({{b, c, r1}, walls, part, false, false, false, 2, 1, "", {}, 3});
|
||||
};
|
||||
// windows as lines on the front (the side towards the viewer, lower y)
|
||||
const auto windows = [&](const std::string &part, double x, double y, double w, double d, double z0, double z1, int count) {
|
||||
Face glassy{{{x - w / 2 + 2, y - d / 2 - .2, z0}, {x + w / 2 - 2, y - d / 2 - .2, z0}, {x + w / 2 - 2, y - d / 2 - .2, z1}, {x - w / 2 + 2, y - d / 2 - .2, z1}}, glass, part, false, false, true, 1.5, 1, "", {}, 4};
|
||||
for (int n = 1; n < count; ++n) glassy.lines.push_back({{x - w / 2 + 2 + (w - 4) * n / count, y - d / 2 - .2, z0}, {x - w / 2 + 2 + (w - 4) * n / count, y - d / 2 - .2, z1}});
|
||||
scene.faces.push_back(glassy);
|
||||
};
|
||||
const auto tree = [&](double x, double y) {
|
||||
scene.faces.push_back({{{x, y, 0}, {x, y, 5}}, "", "", false, true, true, 3, 1, "#6b5335", {}, 2});
|
||||
box(scene, "", x, y, 7, 7, 8, green, false, 5);
|
||||
};
|
||||
const auto car = [&](const std::string &part, double x, double y, int tone) {
|
||||
static constexpr std::array<const char *, 5> paints{"#c8553d", "#3f6f9f", "#e8e2d2", "#5b6168", "#d9b13b"};
|
||||
box(scene, part, x, y, 4.2, 8.5, 2.6, paints[size_t(tone) % paints.size()]);
|
||||
};
|
||||
const auto level_at = [&](size_t i) { return i < periphery.size() ? periphery[i].value("level", 0) : 0; };
|
||||
const auto planned = [&](const std::string &part, double x, double y, double w, double d, bool busy) {
|
||||
box(scene, part, x, y, w, d, 1, wall, true);
|
||||
if (busy) scene.faces.push_back({{{x - w / 2, y - d / 2, 0}, {x + w / 2, y - d / 2, 0}, {x + w / 2, y - d / 2, 14}, {x - w / 2, y - d / 2, 14}}, gold, part, true, false, true, 3, .25, gold, {}, 4});
|
||||
};
|
||||
const auto centre = [&](size_t i, double x, double y, double z) { scene.centres["periphery:" + std::to_string(i)] = {x, y, z}; };
|
||||
const auto busy_at = [&](size_t i) { return i < periphery.size() && building(periphery[i]); };
|
||||
// 0 transport: a road, then a bus stop, a tram line, a station
|
||||
if (!periphery.empty()) {
|
||||
const std::string part = "periphery:0";
|
||||
const int level = level_at(0);
|
||||
if (level <= 0) planned(part, 0, -215, 600, 26, busy_at(0));
|
||||
else {
|
||||
flat(part, 0, -215, 680, 24, asphalt);
|
||||
stripe(-340, -215, 340, -215, white, true);
|
||||
flat(part, 0, -165, 22, 76, asphalt); // the approach to the ground
|
||||
if (level >= 2) { // bus stop: shelter and two buses
|
||||
box(scene, part, -70, -196, 30, 5, 7, glass);
|
||||
box(scene, part, -120, -212, 26, 7, 8, "#d9b13b");
|
||||
box(scene, part, 60, -219, 26, 7, 8, "#d9b13b");
|
||||
}
|
||||
if (level >= 3) { // tram: rails and a tram
|
||||
stripe(-340, -238, 340, -238, slate);
|
||||
stripe(-340, -242, 340, -242, slate);
|
||||
box(scene, part, 150, -240, 44, 6, 8, "#c8553d");
|
||||
box(scene, part, 110, -231, 60, 4, 1.5, plaster);
|
||||
}
|
||||
if (level >= 4) { // station hall
|
||||
gabled(part, -230, -238, 90, 30, 16, 10, brick, slate);
|
||||
windows(part, -230, -238, 90, 30, 4, 12, 9);
|
||||
}
|
||||
if (busy_at(0)) planned(part, -230, -238, 96, 36, true);
|
||||
}
|
||||
centre(0, level >= 4 ? -230 : -70, -215, 6);
|
||||
}
|
||||
scene.centres[part] = {x, y, 6};
|
||||
// 4 parking: a lot per level, with bays and cars
|
||||
if (periphery.size() > 4) {
|
||||
const std::string part = "periphery:4";
|
||||
const int level = level_at(4), most = std::max(1, periphery[4].value("max_level", 3));
|
||||
for (int lot = 0; lot < most; ++lot) {
|
||||
const double x = -262, y = 78 - lot * 78;
|
||||
if (lot >= level) { planned(part, x, y, 110, 62, lot == level && busy_at(4)); continue; }
|
||||
flat(part, x, y, 110, 62, asphalt);
|
||||
for (int bay = 0; bay <= 10; ++bay) { stripe(x - 50 + bay * 10, y - 28, x - 50 + bay * 10, y - 10, white); stripe(x - 50 + bay * 10, y + 10, x - 50 + bay * 10, y + 28, white); }
|
||||
for (int bay = 0; bay < 10; ++bay) {
|
||||
if ((bay * 7 + lot * 3) % 4 != 3) car(part, x - 45 + bay * 10, y - 19, bay + lot);
|
||||
if ((bay * 5 + lot) % 3 != 0) car(part, x - 45 + bay * 10, y + 19, bay * 2 + lot);
|
||||
}
|
||||
}
|
||||
centre(4, -262, 78, 4);
|
||||
}
|
||||
// 2 shopping centre: two wings, a glass front, a roof terrace
|
||||
if (periphery.size() > 2) {
|
||||
const std::string part = "periphery:2";
|
||||
if (level_at(2) <= 0) planned(part, 215, 195, 130, 70, busy_at(2));
|
||||
else {
|
||||
box(scene, part, 215, 205, 130, 44, 20, plaster);
|
||||
box(scene, part, 170, 170, 40, 30, 14, brick);
|
||||
windows(part, 215, 205, 130, 44, 3, 16, 13);
|
||||
windows(part, 170, 170, 40, 30, 3, 10, 4);
|
||||
box(scene, part, 245, 205, 30, 16, 5, glass, false, 20);
|
||||
box(scene, part, 190, 205, 14, 10, 3, slate, false, 20);
|
||||
for (double x : {232.0, 252.0, 272.0}) tree(x, 168);
|
||||
}
|
||||
centre(2, 215, 195, 12);
|
||||
}
|
||||
// 1 arcade: a hall with a sign
|
||||
if (periphery.size() > 1) {
|
||||
const std::string part = "periphery:1";
|
||||
if (level_at(1) <= 0) planned(part, -205, 205, 84, 50, busy_at(1));
|
||||
else {
|
||||
box(scene, part, -205, 205, 84, 46, 15, "#b9a6c9");
|
||||
windows(part, -205, 205, 84, 46, 2, 8, 6);
|
||||
box(scene, part, -205, 184, 46, 3, 7, "#d9b13b", false, 15);
|
||||
box(scene, part, -180, 215, 16, 16, 4, slate, false, 15);
|
||||
}
|
||||
centre(1, -205, 205, 9);
|
||||
}
|
||||
// 3 club house: a pitched roof, a terrace, trees
|
||||
if (periphery.size() > 3) {
|
||||
const std::string part = "periphery:3";
|
||||
if (level_at(3) <= 0) planned(part, 0, 215, 70, 44, busy_at(3));
|
||||
else {
|
||||
gabled(part, 0, 220, 66, 30, 11, 9, plaster, tile);
|
||||
windows(part, 0, 220, 66, 30, 3, 8, 6);
|
||||
flat(part, 0, 197, 66, 14, wood, -400);
|
||||
for (double x : {-24.0, -8.0, 8.0, 24.0}) box(scene, part, x, 197, 5, 5, 2.4, white);
|
||||
tree(-46, 214); tree(46, 214);
|
||||
}
|
||||
centre(3, 0, 215, 8);
|
||||
}
|
||||
// 5 restaurant: a house with an awning and tables
|
||||
if (periphery.size() > 5) {
|
||||
const std::string part = "periphery:5";
|
||||
if (level_at(5) <= 0) planned(part, 262, 70, 60, 44, busy_at(5));
|
||||
else {
|
||||
gabled(part, 262, 78, 56, 30, 12, 8, brick, slate);
|
||||
windows(part, 262, 78, 56, 30, 3, 9, 5);
|
||||
scene.faces.push_back({{{234, 63, 9}, {290, 63, 9}, {290, 52, 6}, {234, 52, 6}}, "#c8553d", part, false, false, false, 2, 1, "", {}, 5});
|
||||
for (double x : {242.0, 256.0, 270.0, 284.0}) box(scene, part, x, 46, 5, 5, 2.4, white);
|
||||
}
|
||||
centre(5, 262, 70, 8);
|
||||
}
|
||||
// 6-9 snack bars: a kiosk with a striped awning
|
||||
const std::array<std::array<double, 2>, 4> kiosks{{{{-128, -138}}, {{128, -138}}, {{-128, 138}}, {{128, 138}}}};
|
||||
for (size_t n = 0; n < 4 && 6 + n < periphery.size(); ++n) {
|
||||
const std::string part = "periphery:" + std::to_string(6 + n);
|
||||
const double x = kiosks[n][0], y = kiosks[n][1];
|
||||
if (level_at(6 + n) <= 0) planned(part, x, y, 26, 20, busy_at(6 + n));
|
||||
else {
|
||||
box(scene, part, x, y, 32, 20, 12, white);
|
||||
box(scene, part, x, y, 34, 22, 2, tile, false, 12);
|
||||
Face awning{{{x - 18, y - 10, 11}, {x + 18, y - 10, 11}, {x + 18, y - 21, 7.5}, {x - 18, y - 21, 7.5}}, "#d9b13b", part, false, false, false, 2, 1, "", {}, 5};
|
||||
for (int s = 1; s < 8; ++s) awning.lines.push_back({{x - 18 + 36.0 * s / 8, y - 10, 11}, {x - 18 + 36.0 * s / 8, y - 21, 7.5}});
|
||||
scene.faces.push_back(awning);
|
||||
for (double dx : {-22.0, -8.0, 8.0, 22.0}) box(scene, part, x + dx, y - 28, 5, 5, 3.4, wood); // standing tables
|
||||
box(scene, part, x + 22, y + 4, 5, 5, 5, slate); // bins
|
||||
}
|
||||
centre(6 + n, x, y, 5);
|
||||
}
|
||||
// 10-13 fan shops: a shop in the club's colour with a flag
|
||||
const std::array<std::array<double, 2>, 4> shops{{{{256, -20}}, {{256, -95}}, {{200, -150}}, {{-200, -150}}}};
|
||||
for (size_t n = 0; n < 4 && 10 + n < periphery.size(); ++n) {
|
||||
const std::string part = "periphery:" + std::to_string(10 + n);
|
||||
const double x = shops[n][0], y = shops[n][1];
|
||||
if (level_at(10 + n) <= 0) planned(part, x, y, 40, 30, busy_at(10 + n));
|
||||
else {
|
||||
box(scene, part, x, y, 48, 30, 13, plaster);
|
||||
windows(part, x, y, 48, 30, 2, 9, 6);
|
||||
box(scene, part, x, y, 50, 32, 3, seats, false, 13);
|
||||
box(scene, part, x - 14, y - 17, 14, 3, 5, seats, false, 9); // the sign over the door
|
||||
scene.faces.push_back({{{x + 20, y + 10, 16}, {x + 20, y + 10, 34}}, "", part, false, true, true, 3, 1, "", {}, 6});
|
||||
scene.faces.push_back({{{x + 20, y + 10, 34}, {x + 33, y + 10, 30.5}, {x + 20, y + 10, 27}}, seats, part, false, false, true, 1.5, 1, "", {}, 7});
|
||||
}
|
||||
centre(10 + n, x, y, 6);
|
||||
}
|
||||
// any further object of a data set: a house that grows with its level
|
||||
for (size_t i = 14; i < periphery.size(); ++i) {
|
||||
const std::string part = "periphery:" + std::to_string(i);
|
||||
const double x = -300 + double(i - 14) * 60, y = -150;
|
||||
if (level_at(i) <= 0) planned(part, x, y, 40, 30, busy_at(i));
|
||||
else box(scene, part, x, y, 30 + 6 * level_at(i), 24, 6 + 5 * level_at(i), brick);
|
||||
centre(i, x, y, 6);
|
||||
}
|
||||
for (double x : {-330.0, -300.0, 300.0, 330.0}) tree(x, 245);
|
||||
for (const auto &[id, at] : scene.centres) scene.anchors.push_back({id, at});
|
||||
return scene;
|
||||
}
|
||||
scene.centres["stadium"] = {0, 0, 0};
|
||||
for (const auto &[id, centre] : scene.centres)
|
||||
@@ -321,6 +496,9 @@ inline Drawing draw(const Scene &scene, const Camera &camera, double width, doub
|
||||
return out;
|
||||
}
|
||||
|
||||
// The camera never moves: one station for the stadium, one for its surroundings.
|
||||
inline Camera fixed_camera(bool surroundings) { return surroundings ? Camera{28, 42, 0.98, 0, 0} : Camera{28, 44, 1.72, 0, 0}; }
|
||||
|
||||
// Where the camera stands for a focus: "" the whole ground with its surroundings, "stadium"
|
||||
// the bowl, a part id that part, turned so that it lies in front.
|
||||
inline Camera camera_for(const Scene &scene, const std::string &focus) {
|
||||
|
||||
@@ -139,57 +139,45 @@ std::string App::render_stadium() {
|
||||
if(body.empty())return std::string();
|
||||
return "<span class=\"stadium-art-overlay\" style=\""+rect(0,0,w,viewport_h)+"\">"+picture(renderer_.diagram("stadium-card-overlay-"+std::to_string(i)+"-"+std::to_string(level)+"-"+theme_,stadium_svg(body,w,viewport_h),1564),w,viewport_h)+"</span>";
|
||||
};
|
||||
std::string out="<div class=\"stadium-screen"+std::string(view=="panorama"?" periphery":"")+"\" id=\"stadium-underlay\">";
|
||||
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"?"Modell · ein Bauteil anklicken":"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") {
|
||||
// the ground as a card model: the camera stands where the focus is, parts are chosen in the picture
|
||||
std::string out="<div class=\"stadium-screen"+std::string()+"\" id=\"stadium-underlay\">";
|
||||
out+="<header class=\"stadium-heading\"><div class=\"stadium-heading-copy\"><h2>"+esc(overview.at("name").get<std::string>())+"</h2><p>"+(view=="inside"?"Stadion · ein Bauteil anklicken":view=="panorama"?"Umfeld · ein Gebäude anklicken":"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"||view=="panorama") {
|
||||
// the ground as a card model seen from a fixed camera: the stadium with its stands and
|
||||
// facilities, or its surroundings; a part is chosen in the picture and shown on a card
|
||||
const bool outer=view=="panorama";
|
||||
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";
|
||||
const auto scene=stadium3d::build(overview,seat_colour,theme_=="silver");
|
||||
if(stadium_focus_!=""&&stadium_focus_!="stadium"&&!scene.centres.contains(stadium_focus_))stadium_focus_="stadium";
|
||||
if(!stadium_flying_)stadium_camera_=stadium3d::camera_for(scene,stadium_focus_);
|
||||
const auto scene=stadium3d::build(overview,seat_colour,theme_=="silver",outer?1:0);
|
||||
if(!stadium_focus_.empty()&&(!scene.centres.contains(stadium_focus_)||stadium_focus_.starts_with("periphery:")!=outer))stadium_focus_.clear();
|
||||
constexpr double mw=1790,mh=1600;
|
||||
const bool part_focus=stadium_focus_.find(':')!=std::string::npos;
|
||||
const auto drawing=stadium3d::draw(scene,stadium_camera_,mw,mh,part_focus?stadium_focus_:std::string());
|
||||
out+="<div class=\"stadium-model\" id=\"stadium-model\"><div id=\"stadium-model-art\">"+picture(renderer_.diagram("stadium-model",drawing.svg,stadium_flying_?1790:3580),mw,mh)+"</div>";
|
||||
const bool part_focus=!stadium_focus_.empty();
|
||||
const auto drawing=stadium3d::draw(scene,stadium3d::fixed_camera(outer),mw,mh,stadium_focus_);
|
||||
out+="<div class=\"stadium-model\" id=\"stadium-model\"><div id=\"stadium-model-art\">"+picture(renderer_.diagram("stadium-model",drawing.svg,3580),mw,mh)+"</div>";
|
||||
const auto name_of=[&](const std::string &id)->std::string {
|
||||
const auto index=size_t(std::stoul(id.substr(id.find(':')+1)));
|
||||
if(id.starts_with("block:"))return "Block "+overview.at("blocks")[index].at("letter").get<std::string>();
|
||||
if(id.starts_with("facility:"))return overview.at("facilities")[index].at("name").get<std::string>();
|
||||
return overview.at("periphery")[index].at("name").get<std::string>();
|
||||
};
|
||||
if(!stadium_flying_) {
|
||||
// a click beside every part leads one level back
|
||||
if(!stadium_focus_.empty())out+=btn("stadium-focus","","stadium-model-back","id=\"stadium-model-ground\" data-id=\""+std::string(part_focus&&!stadium_focus_.starts_with("periphery:")?"stadium":"")+"\" aria-label=\"Zurück\" style=\""+rect(0,0,mw,mh)+"\"");
|
||||
double sx0=mw,sy0=mh,sx1=0,sy1=0;
|
||||
for(const auto &part:drawing.parts)if(part.id.starts_with("block:")){sx0=std::min(sx0,part.x0);sy0=std::min(sy0,part.y0);sx1=std::max(sx1,part.x1);sy1=std::max(sy1,part.y1);}
|
||||
// every part is chosen at its anchors: a spot of a size that follows the zoom
|
||||
const double reach=std::clamp(30*stadium_camera_.zoom,44.0,110.0);
|
||||
std::map<std::string,int> spots;
|
||||
// stands last: where spots overlap, the stand is the one that is hit
|
||||
auto anchors=drawing.anchors;
|
||||
std::stable_sort(anchors.begin(),anchors.end(),[](const auto &a,const auto &b){return !a.id.starts_with("block:")&&b.id.starts_with("block:");});
|
||||
for(const auto &anchor:anchors) {
|
||||
const bool outer=anchor.id.starts_with("periphery:");
|
||||
// the whole ground: the bowl as one part, and the houses around it; inside the bowl: its parts
|
||||
if(stadium_focus_.empty()&&!outer)continue;
|
||||
if(part_focus&&anchor.id==stadium_focus_)continue;
|
||||
if(anchor.x<reach||anchor.y<reach||anchor.x>mw-reach||anchor.y>mh-reach)continue;
|
||||
const auto name=name_of(anchor.id);const int spot=spots[anchor.id]++;
|
||||
out+=btn("stadium-focus","","stadium-model-hit","id=\"stadium-part-"+esc(anchor.id.substr(0,anchor.id.find(':'))+"-"+anchor.id.substr(anchor.id.find(':')+1))+(spot?"-"+std::to_string(spot):std::string())+"\" data-id=\""+esc(anchor.id)+"\" data-stadium-hint=\""+esc(name)+"\" aria-label=\""+esc(name)+"\" style=\""+rect(anchor.x-reach,anchor.y-reach*.8,2*reach,1.6*reach)+"\"");
|
||||
}
|
||||
for(const auto &part:drawing.parts) {
|
||||
if(stadium_focus_.empty()&&!part.id.starts_with("periphery:"))continue;
|
||||
if(part.cx<60||part.cy<60||part.cx>mw-60||part.cy>mh-60)continue;
|
||||
const bool letter=part.id.starts_with("block:");
|
||||
out+="<span class=\"stadium-model-tag"+std::string(letter?" letter":"")+"\" style=\"left:"+scalar(part.cx)+"dp;top:"+scalar(part.cy+(letter?0:reach*.55))+"dp;\"><span>"+esc(letter?overview.at("blocks")[size_t(std::stoul(part.id.substr(6)))].at("letter").get<std::string>():name_of(part.id))+"</span></span>";
|
||||
}
|
||||
if(stadium_focus_.empty()&&sx1>sx0)out+=btn("stadium-focus","<span>Stadion</span>","stadium-model-hit bowl","id=\"stadium-part-stadium\" data-id=\"stadium\" aria-label=\"Stadion ansehen\" style=\""+rect(sx0-10,sy0-10,sx1-sx0+20,sy1-sy0+20)+"\"");
|
||||
if(part_focus)out+=btn("stadium-focus","","stadium-model-back","id=\"stadium-model-ground\" data-id=\"\" aria-label=\"Auswahl aufheben\" style=\""+rect(0,0,mw,mh)+"\"");
|
||||
const double reach=outer?74:62;
|
||||
std::map<std::string,int> spots;
|
||||
// stands last: where spots overlap, the stand is the one that is hit
|
||||
auto anchors=drawing.anchors;
|
||||
std::stable_sort(anchors.begin(),anchors.end(),[](const auto &a,const auto &b){return !a.id.starts_with("block:")&&b.id.starts_with("block:");});
|
||||
for(const auto &anchor:anchors) {
|
||||
if(anchor.id==stadium_focus_)continue;
|
||||
if(anchor.x<reach||anchor.y<reach||anchor.x>mw-reach||anchor.y>mh-reach)continue;
|
||||
const auto name=name_of(anchor.id);const int spot=spots[anchor.id]++;
|
||||
out+=btn("stadium-focus","","stadium-model-hit","id=\"stadium-part-"+esc(anchor.id.substr(0,anchor.id.find(':'))+"-"+anchor.id.substr(anchor.id.find(':')+1))+(spot?"-"+std::to_string(spot):std::string())+"\" data-id=\""+esc(anchor.id)+"\" data-stadium-hint=\""+esc(name)+"\" aria-label=\""+esc(name)+"\" style=\""+rect(anchor.x-reach,anchor.y-reach*.8,2*reach,1.6*reach)+"\"");
|
||||
}
|
||||
out+="<div class=\"stadium-model-path\">"+btn("stadium-focus","Gelände","stadium-model-crumb"+std::string(stadium_focus_.empty()?" here":""),"id=\"stadium-crumb-all\" data-id=\"\"")+
|
||||
btn("stadium-focus","Stadion","stadium-model-crumb"+std::string(stadium_focus_=="stadium"?" here":""),"id=\"stadium-crumb-stadium\" data-id=\"stadium\"")+
|
||||
(part_focus?"<span class=\"stadium-model-crumb here\"><span>"+esc(name_of(stadium_focus_))+"</span></span>":std::string())+"</div></div>";
|
||||
for(const auto &part:drawing.parts) {
|
||||
if(part.cx<60||part.cy<60||part.cx>mw-60||part.cy>mh-60)continue;
|
||||
const bool letter=part.id.starts_with("block:");
|
||||
out+="<span class=\"stadium-model-tag"+std::string(letter?" letter":"")+(part.id==stadium_focus_?" chosen":"")+"\" style=\"left:"+scalar(part.cx)+"dp;top:"+scalar(part.cy+(letter?0:reach*.62))+"dp;\"><span>"+esc(letter?overview.at("blocks")[size_t(std::stoul(part.id.substr(6)))].at("letter").get<std::string>():name_of(part.id))+"</span></span>";
|
||||
}
|
||||
out+="</div>";
|
||||
if(part_focus) {
|
||||
// the part's card: what stands there today, and the way to build on
|
||||
const auto index=size_t(std::stoul(stadium_focus_.substr(stadium_focus_.find(':')+1)));
|
||||
@@ -219,7 +207,16 @@ std::string App::render_stadium() {
|
||||
out+="<aside class=\"stadium-card\" id=\"stadium-card\"><h3>"+esc(name_of(stadium_focus_))+"</h3>"+facts+
|
||||
"<p class=\"stadium-card-note\">"+std::string(busy?"Hier wird gebaut.":full?"Hier ist alles ausgebaut.":"Preis und Bauzeit nennt das Angebot der Baufirma.")+"</p>"+
|
||||
btn(action,label,"primary stadium-card-build","id=\"stadium-card-build\" data-id=\""+std::to_string(index)+"\" "+(busy||full?"disabled=\"disabled\"":""))+
|
||||
btn("stadium-focus","Zurück","stadium-card-back","id=\"stadium-card-back\" data-id=\""+std::string(stadium_focus_.starts_with("periphery:")?"":"stadium")+"\"")+"</aside>";
|
||||
btn("stadium-focus","Zurück","stadium-card-back","id=\"stadium-card-back\" data-id=\"\"")+"</aside>";
|
||||
} else if(outer) {
|
||||
// nothing chosen: every object of the surroundings with its level
|
||||
out+="<aside class=\"stadium-card stadium-list\" id=\"stadium-card\"><h3>Umfeld</h3>";
|
||||
for(size_t i=0;i<overview.at("periphery").size();++i) {
|
||||
const auto &row=overview.at("periphery")[i];const int level=row.at("level").get<int>(),most=row.at("max_level").get<int>();
|
||||
std::string pips="<span class=\"stadium-row-pips\">";for(int k=0;k<most;++k)pips+=k<level?"<span class=\"pip on\"></span>":"<span class=\"pip\"></span>";
|
||||
out+=btn("stadium-focus","<span class=\"name\">"+esc(row.at("name").get<std::string>())+"</span>"+(row.at("building").get<bool>()?"<span class=\"job\">Bau · "+std::to_string(row.at("job").at("weeks").get<int>())+" W.</span>":std::string())+pips+"</span>","stadium-row","id=\"stadium-row-"+std::to_string(i)+"\" data-id=\"periphery:"+std::to_string(i)+"\"");
|
||||
}
|
||||
out+="</aside>";
|
||||
} else {
|
||||
for(size_t i=0;i<8;++i) {
|
||||
const auto &b=overview.at("blocks")[i];const bool building=b.at("building").get<bool>();
|
||||
@@ -229,22 +226,6 @@ std::string App::render_stadium() {
|
||||
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\"":""));
|
||||
}
|
||||
}
|
||||
} else if(view=="panorama") {
|
||||
constexpr double scale=2612.0/1920;
|
||||
out+="<div class=\"stadium-periphery-scene\" id=\"stadium-periphery-scene\">";
|
||||
if(!gui_.contains("stadium.scene"))out+="<p class=\"stadium-empty\">Die kalibrierten Stadionumfeld-Grafiken fehlen im GUI-Paket.</p>";
|
||||
else try {
|
||||
const auto configuration=Json::parse(editor::read_file(gui_.root()/editor::path(gui_.items().at("stadium.scene").at("file").get<std::string>())));
|
||||
const auto scene=demo_stadium_scene(configuration,overview,future);
|
||||
for(const auto &layer:scene.at("layers"))out+="<span class=\"stadium-scene-sprite\" data-owner=\""+esc(layer.at("owner").is_string()?layer.at("owner").get<std::string>():layer.at("owner").dump())+"\" data-role=\""+layer.at("role").get<std::string>()+"\" style=\""+rect(layer.at("x").get<double>()*scale,layer.at("y").get<double>()*scale,layer.at("width").get<double>()*scale,layer.at("height").get<double>()*scale)+"\">"+img("stadium.scene."+layer.at("asset").get<std::string>(),layer.at("width").get<double>()*scale,layer.at("height").get<double>()*scale,false,false,3072)+"</span>";
|
||||
for(const auto &area:scene.at("areas")) {
|
||||
const auto i=area.at("index").get<size_t>();const auto &row=overview.at("periphery")[i];
|
||||
auto hint=row.at("name").get<std::string>();
|
||||
if(row.at("building").get<bool>())hint+=" · noch "+std::to_string(row.at("job").at("weeks").get<int>())+" Wochen";
|
||||
out+=btn("stadium-periphery","","stadium-periphery-hit","id=\"stadium-periphery-"+std::to_string(i)+"\" data-id=\""+std::to_string(i)+"\" data-stadium-hint=\""+esc(hint)+"\" aria-label=\""+esc(hint)+"\" aria-disabled=\""+(row.at("building").get<bool>()||row.at("level")==row.at("max_level")?"true":"false")+"\" style=\""+rect(area.at("x").get<double>()*scale,area.at("y").get<double>()*scale,area.at("width").get<double>()*scale,area.at("height").get<double>()*scale)+"\"");
|
||||
}
|
||||
} catch(const std::exception &) {out+="<p class=\"stadium-empty\">Die Stadionumfeld-Grafiken sind unvollständig.</p>";}
|
||||
out+="</div><p id=\"stadium-interaction-hint\" role=\"status\" aria-live=\"polite\"><span>"+esc(stadium_view_.at("hint").get<std::string>().empty()?"Ein Element im Stadionumfeld auswählen.":stadium_view_.at("hint").get<std::string>())+"</span></p>";
|
||||
} else {
|
||||
if(engine_mode_)out+=engine_stadium_data();
|
||||
else {const auto snapshot=snap();
|
||||
@@ -266,12 +247,12 @@ std::string App::render_stadium() {
|
||||
}
|
||||
out+="<nav class=\"stadium-nav\">";
|
||||
if(view=="panorama") {
|
||||
out+=btn("stadium-back","Zurück","stadium-nav-button half","id=\"stadium-back\"");
|
||||
out+=btn("stadium-back","Zum Stadion","stadium-nav-button half","id=\"stadium-back\"");
|
||||
out+=btn("stadium-future","Zukunft","stadium-nav-button half","id=\"stadium-future\" aria-pressed=\""+std::string(future?"true":"false")+"\"");
|
||||
}
|
||||
else if(view=="data")out+=btn("stadium-back","Zurück zum Stadion","stadium-nav-button wide","id=\"stadium-back\"");
|
||||
else {
|
||||
out+=btn("stadium-view",view=="inside"?"Sicht: Panorama":"Sicht: Innen","stadium-nav-button","id=\"stadium-view\"");
|
||||
out+=btn("stadium-view",view=="inside"?"Zum Umfeld":"Zum Stadion","stadium-nav-button","id=\"stadium-view\"");
|
||||
out+=view=="inside"?btn("stadium-future",std::string("Ausbau: ")+(future?"Zukunft":"Aktuell"),"stadium-nav-button","id=\"stadium-future\" aria-pressed=\""+std::string(future?"true":"false")+"\""):"<button class=\"stadium-nav-button control-button\" disabled=\"disabled\"><span class=\"control-label\">Peripherie bauen</span></button>";
|
||||
out+=btn("stadium-data","Stadion-Daten","stadium-nav-button","id=\"stadium-data\"");
|
||||
}
|
||||
|
||||
@@ -549,21 +549,29 @@ int main(int argc, char **argv) try {
|
||||
for (int i = 0; i < 8; ++i) overview["facilities"].push_back({{"name", "Anlage"}, {"display_level", 2}, {"building", false}});
|
||||
for (int i = 0; i < 14; ++i) overview["periphery"].push_back({{"name", "Haus"}, {"level", i % 3}, {"max_level", 3}, {"building", false}});
|
||||
const auto scene = stadium3d::build(overview, "#aa2233", true);
|
||||
require(scene.centres.contains("block:7") && scene.centres.contains("facility:0") && scene.centres.contains("periphery:13"),
|
||||
"Stadium model misses a selectable part");
|
||||
const auto whole = stadium3d::draw(scene, stadium3d::camera_for(scene, ""), 1790, 1600);
|
||||
const auto again = stadium3d::draw(stadium3d::build(overview, "#aa2233", true), stadium3d::camera_for(scene, ""), 1790, 1600);
|
||||
require(whole.svg == again.svg && whole.svg.size() > 4000,
|
||||
"Stadium model is not drawn the same way twice");
|
||||
require(scene.centres.contains("block:7") && scene.centres.contains("facility:0") && !scene.centres.contains("periphery:0"),
|
||||
"The stadium's view should offer stands and facilities only");
|
||||
const auto inside = stadium3d::fixed_camera(false);
|
||||
const auto whole = stadium3d::draw(scene, inside, 1790, 1600);
|
||||
const auto again = stadium3d::draw(stadium3d::build(overview, "#aa2233", true), inside, 1790, 1600);
|
||||
require(whole.svg == again.svg && whole.svg.size() > 4000, "Stadium model is not drawn the same way twice");
|
||||
require(std::count_if(whole.anchors.begin(), whole.anchors.end(), [](const auto &a) { return a.id == "facility:0"; }) == 4,
|
||||
"Each floodlight mast should choose the floodlights");
|
||||
const auto near = stadium3d::camera_for(scene, "block:5"), far = stadium3d::camera_for(scene, "stadium");
|
||||
require(near.zoom > far.zoom && stadium3d::mix(far, near, 0).zoom == far.zoom && stadium3d::mix(far, near, 1).zoom == near.zoom,
|
||||
"Camera flight does not start and end at its stations");
|
||||
const auto close = stadium3d::draw(scene, near, 1790, 1600, "block:5");
|
||||
const auto chosen = std::find_if(close.parts.begin(), close.parts.end(), [](const auto &p) { return p.id == "block:5"; });
|
||||
require(chosen != close.parts.end() && chosen->cx > 300 && chosen->cx < 1490 && chosen->cy > 300 && chosen->cy < 1300,
|
||||
"The chosen stand does not lie in the middle of the picture");
|
||||
for (const auto &part : whole.parts)
|
||||
if (part.id.starts_with("block:"))
|
||||
require(part.cx > 100 && part.cx < 1690 && part.cy > 100 && part.cy < 1500, "A stand lies outside the fixed camera's picture");
|
||||
// the surroundings: every object is a part of its own, and every level draws more
|
||||
const auto around = stadium3d::build(overview, "#aa2233", true, 1);
|
||||
require(around.centres.size() == 14 && around.centres.contains("periphery:13") && !around.centres.contains("block:0"),
|
||||
"The surroundings should offer their fourteen objects only");
|
||||
auto grown = overview;
|
||||
grown["periphery"][0]["level"] = 4;
|
||||
grown["periphery"][4]["level"] = 3;
|
||||
require(stadium3d::build(grown, "#aa2233", true, 1).faces.size() > around.faces.size() + 20,
|
||||
"Higher levels of road and parking should show more");
|
||||
const auto outside = stadium3d::draw(around, stadium3d::fixed_camera(true), 1790, 1600);
|
||||
for (const auto &anchor : outside.anchors)
|
||||
require(anchor.x > 40 && anchor.x < 1750 && anchor.y > 40 && anchor.y < 1560, "An object of the surroundings lies outside the picture");
|
||||
}
|
||||
auto corrupt = layout;
|
||||
corrupt["objects"]["calendar"]["x"] = 999999;
|
||||
|
||||
Reference in new issue
Block a user