diff --git a/assets/modern/bank.rcss b/assets/modern/bank.rcss index 98add30..87fcc07 100644 --- a/assets/modern/bank.rcss +++ b/assets/modern/bank.rcss @@ -86,3 +86,138 @@ body.matchday .bank-actions .bank-control {decorator:linear-gradient(180deg,#e8d .bank-hotspot {display:flex;align-items:flex-end;justify-content:center;} .bank-tag {display:block;flex-shrink:0;margin-bottom:10dp;padding:6dp 22dp;border:2dp #7b725f88;border-radius:6dp;background-color:#fbfaf6f0;color:#233443;font-family:Display;font-size:34dp;line-height:44dp;white-space:nowrap;} .bank-hotspot:hover .bank-tag {background-color:#ffffff;border-color:#25617a;} + +/* --- The bank's services: sheets of the house with a head, tabs, figures and charts. --- */ +body {--bank-gold:#d9bd7c;--bank-panel:#ffffff0a;} +body.silver {--bank-gold:#9a7a3a;--bank-panel:#ffffff8c;} +.bank-overlay,body.silver .bank-overlay,body.matchday .bank-overlay {border:2dp var(--paper-edge);border-radius:10dp;background-color:transparent;decorator:linear-gradient(175deg,var(--paper-top),var(--paper-bottom));color:var(--text);} +.bank-head {position:absolute;left:0;right:0;top:0;height:150dp;display:flex;align-items:center;padding:0 60dp;border-bottom:4dp var(--bank-gold);} +.bank-brand {display:flex;flex-direction:column;flex-shrink:0;} +.bank-brand strong {display:block;font-family:Display;font-size:30dp;line-height:38dp;font-weight:normal;letter-spacing:3dp;color:var(--bank-gold);} +.bank-brand span {display:block;font-family:Display;font-size:60dp;line-height:68dp;} +.bank-tabs {display:flex;gap:14dp;margin-left:auto;} +.bank-tabs .bank-tab {height:72dp;padding:0 34dp;border:2dp var(--rule);border-radius:36dp;background-color:transparent;decorator:none;font-size:32dp;color:var(--text);} +.bank-tabs .bank-tab:hover {background-color:var(--hover);} +.bank-tabs .bank-tab.selected {border-color:var(--bank-gold);background-color:var(--bank-gold);color:#1d232a;} +.bank-insight {border-left:8dp var(--bank-gold);padding:14dp 30dp;background-color:var(--bank-panel);} +.bank-insight h4 {display:block;margin:0 0 6dp 0;font-family:Display;font-size:34dp;line-height:44dp;font-weight:bold;color:var(--bank-gold);} +.bank-insight p {margin:0;font-size:32dp;line-height:46dp;} +.bank-part-track {height:14dp;border-radius:7dp;background-color:var(--rule);overflow:hidden;} +.bank-part-track>div {height:14dp;border-radius:7dp;background-color:var(--bank-gold);} +/* overview */ +.bank-ring {position:absolute;left:90dp;top:230dp;width:860dp;height:860dp;} +.bank-ring-centre {position:absolute;left:0;top:330dp;width:860dp;text-align:center;} +.bank-ring-centre span {display:block;font-size:34dp;line-height:44dp;color:var(--muted);} +.bank-ring-centre strong {display:block;font-family:Display;font-size:58dp;line-height:76dp;font-weight:bold;} +.bank-parts {position:absolute;left:1080dp;right:60dp;top:240dp;} +.bank-part {height:150dp;} +.bank-part.plain {height:92dp;border-top:2dp var(--rule);padding-top:22dp;} +.bank-part-line {display:flex;align-items:center;height:76dp;font-size:40dp;} +.bank-part-line span,.bank-part-line strong {display:block;flex-shrink:0;} +.bank-part-line .chip {width:30dp;height:30dp;border-radius:15dp;margin-right:24dp;} +.bank-part-line .chip.none {background-color:transparent;} +.bank-part-line .label {flex:1;} +.bank-part-line strong {font-family:Display;font-size:48dp;font-weight:bold;text-align:right;} +.bank-part-line .share {width:220dp;text-align:right;font-size:34dp;color:var(--muted);} +.overview-insight {position:absolute;left:90dp;right:60dp;top:1180dp;} +.overview-note {bottom:40dp;} +/* stocks */ +.stock-table {left:60dp;top:190dp;width:1500dp;height:1340dp;font-size:32dp;} +.stock-row {height:98dp;border-bottom:2dp var(--rule);} +.stock-row.stock-head {height:70dp;color:var(--muted);} +.stock-row.chosen {background-color:var(--selected);} +.stock-row>div,body.silver .stock-row>div,body.matchday .stock-row>div {width:250dp;color:var(--text);} +.stock-row>div:first-child {width:460dp;} +.stock-row>div:nth-child(2) {width:290dp;display:flex;justify-content:flex-end;} +.stock-name[aria-pressed=true] {background-color:transparent;color:var(--text);font-weight:bold;} +.stock-move {display:inline-block;font-size:30dp;} +.stock-move.up {color:var(--win);} +.stock-move.down {color:var(--loss);} +.stock-move.flat {color:var(--muted);} +.stock-detail {position:absolute;left:1620dp;right:60dp;top:190dp;height:1340dp;} +.stock-detail h3 {display:block;margin:0;font-family:Display;font-size:54dp;line-height:64dp;font-weight:bold;} +.stock-quote {display:flex;align-items:baseline;gap:26dp;height:96dp;} +.stock-quote strong {display:block;font-family:Display;font-size:84dp;line-height:96dp;font-weight:bold;} +.stock-quote .stock-move {font-size:38dp;} +.stock-chart,body.silver .stock-chart,body.matchday .stock-chart {position:relative;left:0;top:0;width:920dp;height:500dp;margin-top:10dp;border:2dp var(--rule);border-radius:8dp;background-color:var(--bank-panel);} +.stock-legend {display:flex;align-items:center;height:56dp;margin:0;font-size:26dp;color:var(--muted);} +.stock-legend .key {display:block;width:36dp;height:8dp;border-radius:4dp;margin:0 12dp 0 26dp;} +.stock-legend .key.course {margin-left:0;background-color:#25617a;} +.stock-legend .key.average {background-color:var(--bank-gold);} +.stock-legend .key.high {width:16dp;height:16dp;border-radius:8dp;background-color:var(--win);} +.stock-legend .key.low {width:16dp;height:16dp;border-radius:8dp;background-color:var(--loss);} +.stock-tiles {display:flex;flex-wrap:wrap;gap:14dp;width:932dp;} +.stock-tile {width:296dp;height:128dp;border:2dp var(--rule);border-radius:8dp;display:flex;flex-direction:column;align-items:center;justify-content:center;background-color:var(--bank-panel);} +.stock-tile strong {display:block;font-family:Display;font-size:42dp;line-height:52dp;font-weight:bold;white-space:nowrap;} +.stock-tile span {display:block;font-size:26dp;line-height:34dp;color:var(--muted);} +.stock-tile.up strong {color:var(--win);} +.stock-tile.down strong {color:var(--loss);} +.stock-detail .bank-insight {margin-top:20dp;} +.stock-detail .bank-insight p {font-size:30dp;line-height:42dp;} +/* properties */ +.property-card {position:absolute;top:200dp;width:1216dp;height:1330dp;border:2dp var(--rule);border-radius:10dp;background-color:var(--bank-panel);padding:28dp 32dp;} +.property-card.owned-property {left:60dp;} +.property-card.offered-property {left:1336dp;} +.property-card h3 {display:block;margin:0 0 18dp 0;font-size:30dp;line-height:40dp;font-weight:normal;letter-spacing:2dp;color:var(--bank-gold);} +.property-card h4 {display:block;margin:26dp 0 10dp 0;font-family:Display;font-size:54dp;line-height:66dp;font-weight:bold;} +.property-card .property-picture {width:1150dp;height:654dp;border:2dp var(--paper-edge);border-radius:8dp;} +.property-empty,body.silver .property-empty {display:flex;align-items:center;justify-content:center;width:100%;height:100%;background-color:var(--rule);} +.property-empty span {display:block;font-size:34dp;color:var(--muted);} +.bank-fact {display:flex;align-items:center;justify-content:space-between;height:70dp;border-bottom:2dp var(--rule);font-size:34dp;} +.bank-fact span,.bank-fact strong {display:block;} +.bank-fact strong {font-family:Display;font-size:40dp;font-weight:bold;} +.property-hint {margin:22dp 0 0 0;font-size:28dp;color:var(--muted);} +/* savings: the passbook lies on the sheet */ +.savings-overlay,body.silver .savings-overlay,body.matchday .savings-overlay {background-color:transparent;} +.passbook {left:256dp;top:210dp;border-radius:44dp;overflow:hidden;} +.passbook-cash {position:absolute;left:0;right:0;top:240dp;text-align:right;font-size:34dp;color:#5b4837;} +/* credit */ +.credit-portrait {left:60dp;top:200dp;border:2dp var(--paper-edge);border-radius:8dp;} +.credit-facts.engine-credit {left:750dp;right:60dp;top:196dp;width:auto;height:520dp;} +.engine-credit .credit-fact {height:62dp;border-bottom:2dp var(--rule);align-items:center;font-size:32dp;} +.engine-credit .credit-fact>span {width:auto;} +.engine-credit .credit-fact>strong,body.silver .engine-credit .credit-fact>strong {width:auto;font-family:Display;font-size:36dp;font-weight:bold;color:var(--text);} +.engine-credit .credit-fact .bank-control {width:620dp;height:52dp;font-size:32dp;border:2dp var(--bank-gold);border-radius:8dp;} +.credit-schedule,body.silver .credit-schedule,body.matchday .credit-schedule {left:60dp;right:60dp;top:770dp;border:2dp var(--rule);border-radius:10dp;background-color:var(--bank-panel);} +.credit-schedule.engine-credit {height:620dp;} +.credit-schedule-caption h3 {font-family:Display;font-size:40dp;font-weight:bold;} +.credit-tiles {position:absolute;left:36dp;right:36dp;top:110dp;width:auto;} +.credit-tiles .stock-tile {width:780dp;height:170dp;} +.credit-tiles .stock-tile strong {font-size:54dp;line-height:66dp;} +.credit-progress {position:absolute;left:36dp;right:36dp;top:330dp;} +.credit-progress-label {display:flex;justify-content:space-between;height:60dp;font-size:32dp;} +.credit-progress-label span,.credit-progress-label strong {display:block;} +.credit-schedule.engine-credit .credit-schedule-note {top:auto;bottom:28dp;} +.bank-actions {left:60dp;right:60dp;} + +/* second pass */ +.stock-row {height:104dp;} +.stock-row>div,body.silver .stock-row>div,body.matchday .stock-row>div {flex:1;width:auto;} +.stock-row>div:first-child {flex:none;width:430dp;} +.stock-row>div:nth-child(2) {flex:none;width:300dp;} +.stock-row>div:last-child {padding-right:24dp;} +.stock-name,.stock-name.control-button {justify-content:flex-start;text-align:left;} +.stock-chart,body.silver .stock-chart,body.matchday .stock-chart {height:500dp;} +.stock-legend span {display:block;flex-shrink:0;} +.stock-tile {height:138dp;} +.bank-market {position:absolute;left:90dp;right:60dp;top:1370dp;height:400dp;} +.bank-market h4 {display:block;margin:0 0 8dp 0;font-family:Display;font-size:34dp;line-height:44dp;font-weight:bold;color:var(--bank-gold);} +.bank-market-bars {display:flex;height:340dp;} +.bank-market-column {flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;} +.bank-market-column .rise {height:150dp;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;border-bottom:2dp var(--rule);width:100%;} +.bank-market-column .fall {height:150dp;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;} +.bank-market-column .bar {width:64dp;border-radius:4dp;} +.bank-market-column .bar.up {background-color:var(--win);} +.bank-market-column .bar.down {background-color:var(--loss);} +.bank-market-column span {display:block;font-size:24dp;line-height:30dp;color:var(--muted);} +.bank-market-column strong {display:block;font-size:26dp;line-height:36dp;font-weight:normal;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;} +.property-prices {margin-top:22dp;} +.property-prices h5 {display:block;margin:0 0 8dp 0;font-size:28dp;line-height:38dp;font-weight:normal;letter-spacing:2dp;color:var(--bank-gold);} +.property-price {display:flex;align-items:center;height:44dp;font-size:28dp;} +.property-price span {display:block;flex-shrink:0;} +.property-price .name {width:340dp;} +.property-price .bank-part-track {flex:1;} +.property-price .sum {width:300dp;text-align:right;} +.property-price.chosen .name,.property-price.chosen .sum {font-weight:bold;} +.property-price.chosen .bank-part-track>div {background-color:#25617a;} +.bank-market-column strong {width:100%;text-align:center;flex-shrink:0;height:36dp;} diff --git a/assets/modern/entry.rcss b/assets/modern/entry.rcss index 8b9596f..83555c1 100644 --- a/assets/modern/entry.rcss +++ b/assets/modern/entry.rcss @@ -135,7 +135,7 @@ body.matchday {--entry-focus:#efb2aa;--entry-selected:#d48c7b26;--entry-accent-b .entry-manager-underlay[aria-hidden=true] {pointer-events:none;} .entry-dialog-layer {position:absolute;left:-52dp;right:-52dp;top:-40dp;bottom:-24dp;z-index:35;display:flex;align-items:center;justify-content:center;padding:70dp;background-color:#08101980;} -.entry-dialog {width:1700dp;max-height:1800dp;padding:40dp 52dp;border:2dp var(--border);border-radius:22dp;background-color:var(--entry-dialog);overflow-y:auto;overflow-x:hidden;box-shadow:0dp 24dp 70dp #0007;} +.entry-dialog {width:1700dp;max-height:1800dp;padding:40dp 52dp;border:2dp var(--border);border-radius:22dp;background-color:var(--entry-dialog);overflow-y:auto;overflow-x:hidden;} .entry-dialog>h2 {margin:0;font-size:42dp;font-weight:bold;color:var(--text);} .entry-dialog>p {margin:36dp 0;font-size:36dp;line-height:1.5;} .entry-confirm-identity {display:flex;align-items:center;gap:40dp;margin:48dp 0;} diff --git a/assets/modern/environment.rcss b/assets/modern/environment.rcss index 6aa001a..1d042da 100644 --- a/assets/modern/environment.rcss +++ b/assets/modern/environment.rcss @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-3.0-only */ /* Diamond 3.6: six budgets surrounding the club's crest, no additional footer. */ .environment-ring {position:absolute;left:0;top:0;width:2612dp;height:1864dp;} -.environment-card {position:absolute;padding:18dp;border:2dp var(--border);border-radius:20dp;background-color:var(--panel);color:var(--text);text-align:center;box-shadow:0dp 10dp 28dp #0002;} +.environment-card {position:absolute;padding:18dp;border:2dp var(--border);border-radius:20dp;background-color:var(--panel);color:var(--text);text-align:center;} .environment-card h2 {position:absolute;left:18dp;right:18dp;top:18dp;height:36dp;margin:0;font-size:30dp;line-height:36dp;font-weight:normal;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} .environment-stars {position:absolute;left:18dp;right:18dp;top:66dp;height:58dp;padding:4dp;border:2dp var(--border);border-radius:12dp;background-color:var(--panel);display:flex;align-items:center;justify-content:center;} .environment-level {position:relative;display:flex;align-items:center;justify-content:center;flex:1;min-width:0;height:46dp;margin:0;padding:0;border:0dp;border-radius:7dp;background-color:transparent;font-size:40dp;} diff --git a/assets/modern/live.rcss b/assets/modern/live.rcss index 03a3bfc..d655534 100644 --- a/assets/modern/live.rcss +++ b/assets/modern/live.rcss @@ -169,7 +169,7 @@ body.matchday {--live-bg:#242426;--live-surface:#302f34ec;--live-wash:#efc7ce0a; .live-clock {display:flex;align-items:center;justify-content:center;gap:22dp;width:100%;height:96dp;} .live-clock-text {display:block;font-family:Display;font-size:52dp;color:#f4f6f8;} .live-clock-inline {display:block;font-size:28dp;color:#c8d2da;} -.live-plate {display:flex;width:420dp;height:150dp;border:3dp #ffffff30;border-radius:14dp;overflow:hidden;box-shadow:0dp 6dp 18dp #00000080;} +.live-plate {display:flex;width:420dp;height:150dp;border:3dp #ffffff30;border-radius:14dp;overflow:hidden;} .live-game.duo .live-plate {width:330dp;height:130dp;} .live-game.quad .live-plate {width:240dp;height:92dp;} .live-plate-half {flex:1;display:flex;align-items:center;justify-content:center;} @@ -184,7 +184,7 @@ body.matchday {--live-bg:#242426;--live-surface:#302f34ec;--live-wash:#efc7ce0a; .live-timeline {display:flex;justify-content:center;height:112dp;} .live-game.quad .live-timeline {height:84dp;} @keyframes live-moment-in {from {opacity:0;transform:translateX(-220dp);} to {opacity:1;transform:translateX(0dp);}} -.live-moment {position:absolute;left:0;right:0;top:120dp;height:260dp;display:flex;align-items:center;justify-content:center;gap:48dp;border-top:4dp #ffffffb0;border-bottom:4dp #ffffffb0;box-shadow:0dp 10dp 40dp #000000a0;color:#ffffff;pointer-events:none;} +.live-moment {position:absolute;left:0;right:0;top:120dp;height:260dp;display:flex;align-items:center;justify-content:center;gap:48dp;border-top:4dp #ffffffb0;border-bottom:4dp #ffffffb0;color:#ffffff;pointer-events:none;} .live-game.quad .live-moment {top:44dp;height:150dp;gap:28dp;} .live-moment.fresh {animation:0.45s cubic-out live-moment-in;} body.calm .live-moment.fresh {animation:none;} diff --git a/assets/modern/news.rcss b/assets/modern/news.rcss index 490c7c2..eea7a20 100644 --- a/assets/modern/news.rcss +++ b/assets/modern/news.rcss @@ -59,7 +59,7 @@ .news-empty-art>span {position:absolute;left:0;right:0;top:30dp;width:100%;height:0;border-top:3dp var(--muted);} .news-detail-layer {position:absolute;left:0;right:0;top:0;bottom:0;z-index:20;} .news-detail-shade {position:absolute;left:0;right:0;top:0;bottom:0;background-color:#08101980;} -.news-detail-box {position:absolute;left:64dp;right:64dp;top:50%;max-height:1552dp;overflow-y:auto;transform:translate(0,-50%);padding:40dp 52dp;border:2dp var(--border);border-radius:22dp;background-color:#283542f5;box-shadow:0dp 24dp 70dp #0007;font-size:36dp;} +.news-detail-box {position:absolute;left:64dp;right:64dp;top:50%;max-height:1552dp;overflow-y:auto;transform:translate(0,-50%);padding:40dp 52dp;border:2dp var(--border);border-radius:22dp;background-color:#283542f5;font-size:36dp;} .news-detail-box h2 {font-size:42dp;font-weight:bold;letter-spacing:-0.4dp;text-align:center;line-height:1.2;margin-bottom:35dp;} .news-detail {padding-top:0;} .news-detail-meta {display:flex;align-items:center;gap:28dp;margin-bottom:38dp;} diff --git a/assets/modern/settings.rcss b/assets/modern/settings.rcss index a8abddb..944a18f 100644 --- a/assets/modern/settings.rcss +++ b/assets/modern/settings.rcss @@ -72,7 +72,7 @@ body.matchday {--settings-focus:#efb2aa;--settings-tab:#d48c7b26;--settings-sele .preview-widget.two {left:64%;right:18dp;} .preview-app {position:absolute;top:164dp;width:45dp;height:45dp;border-radius:12dp;decorator:linear-gradient(145deg,#7da4aa,#376784);} .preview-app.app-one {left:12%;}.preview-app.app-two {left:41%;}.preview-app.app-three {left:72%;} -.preview-window {position:absolute;left:30%;right:10%;top:56dp;bottom:24dp;padding:38dp 16dp 12dp;border:1dp #a6c7d755;border-radius:10dp;decorator:linear-gradient(155deg,#303c49eb,#1a2531f2);box-shadow:0dp 8dp 20dp #0005;} +.preview-window {position:absolute;left:30%;right:10%;top:56dp;bottom:24dp;padding:38dp 16dp 12dp;border:1dp #a6c7d755;border-radius:10dp;decorator:linear-gradient(155deg,#303c49eb,#1a2531f2);} .preview-title {position:absolute;left:0;right:0;top:0;height:26dp;border-bottom:1dp #a6c7d755;} .preview-title>span {position:absolute;left:10dp;top:9dp;width:8dp;height:8dp;border-radius:4dp;background-color:#fa6a60;} .preview-line {position:relative;display:block;width:100%;height:62dp;margin-bottom:8dp;border-radius:3dp;background-color:#a6c7d755;opacity:0.45;} diff --git a/assets/modern/toto.rcss b/assets/modern/toto.rcss index 992b3cd..665ef6d 100644 --- a/assets/modern/toto.rcss +++ b/assets/modern/toto.rcss @@ -23,7 +23,7 @@ .toto-club-name {display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;} .toto-home .toto-club-name {text-align:right;} .toto-program-note {position:absolute;left:38dp;right:38dp;top:1228dp;font-size:28dp;line-height:36dp;color:var(--muted);margin:0;} -.toto-coupon {position:absolute;left:1152.265625dp;top:0;width:1459.734375dp;height:1614dp;padding:28dp;border:2dp #dfc9b9;border-radius:4dp;background-color:#fff8ed;color:#bd302c;overflow:hidden;box-shadow:0dp 18dp 40dp #0004;} +.toto-coupon {position:absolute;left:1152.265625dp;top:0;width:1459.734375dp;height:1614dp;padding:28dp;border:2dp #dfc9b9;border-radius:4dp;background-color:#fff8ed;color:#bd302c;overflow:hidden;} .toto-print-mark {position:absolute;left:8dp;width:5dp;height:40dp;background-color:#bd302c;} .toto-print-mark.top {top:30dp;}.toto-print-mark.bottom {bottom:30dp;} .toto-paper-heading {position:absolute;left:28dp;right:28dp;top:28dp;height:154dp;border-bottom:3dp #bd302c;display:flex;align-items:center;justify-content:space-between;} @@ -66,7 +66,7 @@ .toto-control {display:flex;align-items:center;justify-content:center;flex:1;min-width:0;padding:8dp 15dp;border:2dp var(--border);border-radius:12dp;background-color:transparent;decorator:linear-gradient(180deg,#c1d1e31c,#869eb312);font-size:30dp;} .toto-control>span {display:block;width:100%;white-space:nowrap;text-align:center;} .toto-layer {position:absolute;left:0;right:0;top:0;bottom:0;display:flex;align-items:center;justify-content:center;background-color:#08101980;z-index:30;} -.toto-dialog {width:2484dp;padding:40dp 52dp;border:2dp var(--border);border-radius:22dp;background-color:#283542f5;font-size:36dp;box-shadow:0dp 24dp 70dp #0007;} +.toto-dialog {width:2484dp;padding:40dp 52dp;border:2dp var(--border);border-radius:22dp;background-color:#283542f5;font-size:36dp;} .toto-dialog h2 {width:100%;font-size:42dp;line-height:48dp;font-weight:bold;letter-spacing:-.4dp;text-align:center;margin:0 0 35dp;} .toto-dialog.receipt {height:1172dp;background-color:#283542;} .toto-receipt {width:100%;height:820dp;overflow-y:auto;} diff --git a/src/modern/app/modern_session.cpp b/src/modern/app/modern_session.cpp index 53e8e7a..ec35aea 100644 --- a/src/modern/app/modern_session.cpp +++ b/src/modern/app/modern_session.cpp @@ -9482,7 +9482,10 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co const auto& s = b.stocks[i]; A history; for (uint16_t h : s.history) history.push_back(modern::ui_money(h)); - stocks.push_back(O{{"id", "stock:" + std::to_string(i)}, {"name", b.finance_stock_labels[i]}, + // the company's name from the game's texts; the bank state only labels held stocks + std::string company; + try { company = ui::original_to_utf8(message_text(g_, ::bmh::layout::Bank_FormatError_ExecutableField2 + uint32_t(i) * 4)); } catch (const std::exception&) {} + stocks.push_back(O{{"id", "stock:" + std::to_string(i)}, {"name", company}, {"price", modern::ui_money(s.price)}, {"previousPrice", modern::ui_money(s.previous_price)}, {"owned", int(s.owned)}, {"paid", modern::ui_money(s.paid)}, {"maxToBuy", s.max_to_buy}, {"history", std::move(history)}}); @@ -9490,7 +9493,14 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co for (size_t i = 0; i < b.funds.size(); ++i) { const auto& f = b.funds[i]; if (f.price == 0) continue; // a fund the game does not offer - funds.push_back(O{{"id", "fund:" + std::to_string(i)}, {"name", f.name}, {"price", modern::ui_money(f.price)}, + // the game keeps a property's name as a stem and its singular and plural endings + // apart ("Reihenh" + "aus" / "äuser"); a catalogue names one of it + std::string property = f.name; + try { + property = ui::original_to_utf8(message_text(g_, ::bmh::layout::Bank_OriginalToUtf8_TextPointer3 + uint32_t(i) * 4) + + exe_.cstring(exe_.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField + uint32_t(i) * 8))); + } catch (const std::exception&) {} + funds.push_back(O{{"id", "fund:" + std::to_string(i)}, {"name", property}, {"price", modern::ui_money(f.price)}, {"owned", int(f.owned)}, {"paid", modern::ui_money(f.paid)}, {"maxToBuy", f.max_to_buy}}); } return modern::ui_snapshot(g_, context, request_id, diff --git a/src/modern/ui/advertising_screens.inc b/src/modern/ui/advertising_screens.inc index 62e84a6..c6f4755 100644 --- a/src/modern/ui/advertising_screens.inc +++ b/src/modern/ui/advertising_screens.inc @@ -59,7 +59,7 @@ std::string App::render_advertising() { btn("ad-accept", active ? "Vertrag läuft" : accept ? "Annehmen" : "Nicht verfügbar", "advertising-control", "id=\"ad-accept\" " + std::string(accept ? "" : "disabled")) + ""; } if (engine_mode_) out += "Vereinsprognose / Monat"; - out += "
"; + out += "
"; for (const auto &[label, key] : std::array, 3>{{{"Einnahmen", "income"}, {"Ausgaben", "expenses"}, {"Saldo", "balance"}}}) out += "
" + std::string(label) + "" + esc(ad_cash(view.at(key).get())) + "
"; return out + "
"; diff --git a/src/modern/ui/bank_screens.inc b/src/modern/ui/bank_screens.inc index 1b4661f..7322309 100644 --- a/src/modern/ui/bank_screens.inc +++ b/src/modern/ui/bank_screens.inc @@ -49,60 +49,188 @@ std::string App::render_bank() { if (bank_view_ == "entrance") return out + "

" + esc(bank_hint_.empty() ? "Ein Element in der Bankhalle auswählen." : bank_hint_) + "

"; - out += "
"; + // Every service of the bank shares one head: the house's name, the service, and tabs that + // lead to the other services without a walk back through the hall. + const std::array, 5> bank_tabs{{{"overview", "Übersicht"}, {"stocks", "Aktien"}, {"properties", "Immobilien"}, {"savings", "Sparbuch"}, {"credit", "Kredit"}}}; + std::string service; + for (const auto &[id, label] : bank_tabs) if (bank_view_ == id) service = label; + out += "
Waldpark Bank" + + service + "
"; + const auto one = [](double value) { + std::ostringstream text; + text << std::fixed << std::setprecision(1) << value; + auto result = text.str(); + std::replace(result.begin(), result.end(), '.', ','); + return result; + }; + // what the club owns, by where it lies + const int64_t in_cash = summary.at("cash").get(), in_deposit = summary.at("deposit").get(), + in_property = summary.at("properties").get(), in_stock = summary.at("stocks").get(); + const int64_t wealth = std::max(0, in_cash) + in_deposit + in_property + in_stock; + const auto share = [&](int64_t part) { return wealth > 0 ? one(std::max(0, part) * 100.0 / wealth) + " %" : std::string("—"); }; + const std::string ink = theme_ == "silver" ? "#233443" : "#e8eef2", faint = theme_ == "silver" ? "#4a433430" : "#dfeaf530", + up = theme_ == "silver" ? "#3f7d63" : "#8fd3ad", down = theme_ == "silver" ? "#a23f45" : "#f0a6a7", + gold = theme_ == "silver" ? "#9a7a3a" : "#d9bd7c", line = theme_ == "silver" ? "#25617a" : "#9ac7d8"; + // an engine name arrives in capitals + const auto calm_name = [](std::string name) { + bool first = true; + std::string result; + for (size_t i = 0; i < name.size(); ++i) { + const unsigned char c = static_cast(name[i]); + if (c == 0xc3 && i + 1 < name.size()) { // Ä Ö Ü + unsigned char next = static_cast(name[i + 1]); + if (!first && (next == 0x84 || next == 0x96 || next == 0x9c)) next = static_cast(next + 0x20); + result += name[i]; result += static_cast(next); ++i; first = false; + continue; + } + if (std::isalpha(c)) { result += static_cast(first ? c : std::tolower(c)); first = false; } + else { result += name[i]; if (c == ' ' || c == '-') first = true; } + } + return result; + }; + const auto factor = engine_mode_ ? 100 : finance_currency_factor(*world_); + const auto course = [&](int index) { + std::vector history; + const auto &stock = assets.at("stocks")[size_t(index)]; + if (engine_mode_) { + for (const auto &value : stock.at("history")) if (value.get() > 0) history.push_back(value.get() / factor); + } else { + const double price = stock.at("price").get() / factor; + for (int i = 0; i < 30; ++i) history.push_back(price * (.85 + .08 * std::sin(i * .6 + index) + i * .003)); + } + return history; + }; if (bank_view_ == "savings") { out += "
" + img("art.bank-passbook-v1.png", 2100, 1293.109375, false, false, 2400) + "

Waldpark Bank

Sparbuch

Bitte beachten Sie:

" "

" + std::string(engine_mode_ ? "Einzahlungen und Abhebungen werden nach Bestätigung im Spielstand verbucht." : "Einzahlungen und Abhebungen werden hier als fiktive Vorschau verbucht.") + "

" - "

" + (engine_mode_ ? "" : "2,5 % Beispielzins") + "

Guthaben

" + - esc(bank_money(snapshot.state.at("deposit").get())) + "
" + actions("Einzahlen", "deposit", "Abheben", "withdraw"); + "

" + (engine_mode_ ? "Anteil am Vermögen: " + share(in_deposit) : std::string("2,5 % Beispielzins")) + "

Guthaben

" + + esc(bank_money(snapshot.state.at("deposit").get())) + "

Auf dem Konto: " + esc(bank_money(in_cash)) + "

" + actions("Einzahlen", "deposit", "Abheben", "withdraw"); } else if (bank_view_ == "properties") { - out += "

Immobilien

"; const auto &owned = assets.at("properties")[size_t(bank_owned_)], &offer = assets.at("properties")[size_t(bank_property_)]; const auto count = finance.at("properties")[size_t(bank_owned_)].get(); - out += "

Ihre Immobilien

" + - (count ? "

" + std::to_string(count) + " × " + esc(owned.at("name").get()) + "

Wert: " + - esc(bank_money(count * owned.at("price").get())) + "

" : "

Keine Immobilien im Bestand

") + - "
" + btn("property-owned-next", count ? img(engine_mode_ ? owned.at("image").get() : "bank.property." + std::to_string(bank_owned_), 996, 566, false, false, 1200) - : "", "property-picture", "id=\"property-owned-next\" aria-label=\"Nächste eigene Immobilie\" " + std::string(count ? "" : "disabled")) + "
"; - out += "

Kaufangebot

" + - esc(offer.at("name").get()) + "

Kaufpreis: " + esc(bank_money(offer.at("price").get())) + - "

" + btn("property-next", img(engine_mode_ ? offer.at("image").get() : "bank.property." + std::to_string(bank_property_), 996, 566, false, false, 1200), - "property-picture", "id=\"property-next\" aria-label=\"Nächstes Immobilienangebot\"") + "
" + + int64_t houses = 0; + for (const auto &held : finance.at("properties")) houses += held.get(); + const auto fact = [](const std::string &label, const std::string &value) { return "
" + label + "" + value + "
"; }; + out += "

Dein Bestand

" + + btn("property-owned-next", count ? img(engine_mode_ ? owned.at("image").get() : "bank.property." + std::to_string(bank_owned_), 1150, 653.5, false, false, 1400) + : "Noch keine Immobilie im Bestand", "property-picture", "id=\"property-owned-next\" aria-label=\"Nächste eigene Immobilie\" " + std::string(count ? "" : "disabled")) + + (count ? "

" + esc(calm_name(owned.at("name").get())) + "

" + fact("Im Bestand", number(count) + " Stück") + + fact("Wert heute", esc(bank_money(count * owned.at("price").get()))) + : "

Kein Bestand

" + fact("Immobilienwert", esc(bank_money(in_property))) + fact("Anteil am Vermögen", share(in_property))) + + "
Preise im Vergleich · " + number(houses) + " im Bestand
"; + { + int64_t dearest = 1; + for (const auto &item : assets.at("properties")) dearest = std::max(dearest, item.at("price").get()); + for (int i = 0; i < property_count; ++i) { + const auto &item = assets.at("properties")[size_t(i)]; + out += "
()) + "\">" + esc(calm_name(item.at("name").get())) + + "
() * 100.0 / dearest) + "%;\">
" + + esc(bank_money(item.at("price").get())) + "
"; + } + } + out += "
"; + out += "

Kaufangebot " + std::to_string(bank_property_ + 1) + " von " + std::to_string(property_count) + "

" + + btn("property-next", img(engine_mode_ ? offer.at("image").get() : "bank.property." + std::to_string(bank_property_), 1150, 653.5, false, false, 1400), + "property-picture", "id=\"property-next\" aria-label=\"Nächstes Immobilienangebot\"") + + "

" + esc(calm_name(offer.at("name").get())) + "

" + fact("Kaufpreis", esc(bank_money(offer.at("price").get()))) + + fact("Anteil am Konto", in_cash > 0 ? one(offer.at("price").get() * 100.0 / in_cash) + " %" : std::string("—")) + + (offer.contains("maxToBuy") ? fact("Bezahlbar", number(offer.at("maxToBuy").get()) + " Stück") : std::string()) + + "

Das Bild anklicken, um das nächste Angebot zu sehen.

" + actions("Kaufen", "property-buy", "Verkaufen", "property-sell"); } else if (bank_view_ == "stocks") { - out += "

Aktien

"; - for (const auto *label : {"Wert", "Kurs", "Vortag", "Bestand"}) out += "
" + std::string(label) + "
"; + const auto move = [&](double from, double to) { + if (from <= 0) return std::string("—"); + const double change = (to - from) * 100.0 / from; + return std::string(" 0.05 ? "up" : change < -0.05 ? "down" : "flat") + "\">" + + (change > 0.05 ? "▲ +" : change < -0.05 ? "▼ −" : "") + one(std::abs(change)) + " %"; + }; + out += "
"; + for (const auto *label : {"Wert", "30 Tage", "Kurs", "zum Vortag", "Bestand"}) out += "
" + std::string(label) + "
"; out += "
"; - const auto factor = engine_mode_ ? 100 : finance_currency_factor(*world_); for (int i = 0; i < stock_count; ++i) { const auto &s = assets.at("stocks")[size_t(i)]; - out += "
" + btn("bank-stock", esc(s.at("name").get()), "stock-name", + const auto history = course(i); + std::string spark = ""; + if (history.size() > 1) { + const double lo = *std::min_element(history.begin(), history.end()), hi = std::max(lo + .01, *std::max_element(history.begin(), history.end())); + std::string points; + for (size_t at = 0; at < history.size(); ++at) points += scalar(4 + at * 232.0 / (history.size() - 1)) + "," + scalar(54 - (history[at] - lo) / (hi - lo) * 48) + " "; + spark += "= history.front() ? up : down) + "\" stroke-width=\"4\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/>"; + } + spark += ""; + out += "
" + btn("bank-stock", esc(s.at("name").get()), "stock-name", "id=\"bank-stock-" + std::to_string(i) + "\" data-bank-stock=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + - "\" aria-pressed=\"" + (i == bank_stock_ ? "true" : "false") + "\"") + "
" + - number(s.at("price").get() / factor) + "
" + number(s.at("previous").get() / factor) + - "
" + number(finance.at("stocks")[size_t(i)].get()) + "
"; + "\" aria-pressed=\"" + (i == bank_stock_ ? "true" : "false") + "\"") + "
" + picture(renderer_.diagram("bank-spark-" + std::to_string(i), spark, 480), 240, 60) + + "
" + number(s.at("price").get() / factor) + "
" + move(s.at("previous").get(), s.at("price").get()) + + "
" + number(finance.at("stocks")[size_t(i)].get()) + "
"; } - const double price = assets.at("stocks")[size_t(bank_stock_)].at("price").get() / factor; - std::vector history; - if (engine_mode_) { - for (const auto &value : assets.at("stocks")[size_t(bank_stock_)].at("history")) history.push_back(value.get() / factor); - } else for (int i = 0; i < 30; ++i) history.push_back(price * (.85 + .08 * std::sin(i * .6 + bank_stock_) + i * .003)); - const double lo = history.empty() ? 0 : *std::min_element(history.begin(), history.end()) * .95; - const double hi = history.empty() ? 1 : std::max(lo + 1., *std::max_element(history.begin(), history.end()) * 1.05); - std::string points; - for (size_t i = 0; i < history.size(); ++i) points += scalar(20 + i * 690. / std::max(1, history.size() - 1)) + "," + scalar(900 - (history[size_t(i)] - lo) / (hi - lo) * 830) + " "; - const auto stroke = theme_ == "silver" ? "#526779" : theme_ == "matchday" ? "#b7b4b9" : "#9ac7d8"; - const auto axis = theme_ == "silver" ? "#526779" : theme_ == "matchday" ? "#b7b4b9" : "#6c8798"; - const auto svg = "" - "" - ""; - out += "
()) + "\">" + - picture(renderer_.diagram("bank-stock", svg, 1600), 740, 1320) + "
" + actions("Kaufen", "stock-buy", "Verkaufen", "stock-sell"); + out += "
"; + // the chosen stock: its course with a five-day average, its range, and what the numbers say + const auto &chosen = assets.at("stocks")[size_t(bank_stock_)]; + const auto history = course(bank_stock_); + const double price = chosen.at("price").get() / factor; + out += "

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

" + number(chosen.at("price").get() / factor) + + "" + move(chosen.at("previous").get(), chosen.at("price").get()) + "
"; + if (history.size() > 1) { + const double lo = *std::min_element(history.begin(), history.end()), hi = *std::max_element(history.begin(), history.end()); + const double floor = lo * .97, ceiling = std::max(floor + 1., hi * 1.03); + const auto px = [&](size_t at) { return 30 + at * 860.0 / (history.size() - 1); }; + const auto py = [&](double value) { return 470 - (value - floor) / (ceiling - floor) * 430; }; + std::string svg = ""; + for (int row = 0; row < 5; ++row) svg += ""; + std::string points, average; + size_t high_at = 0, low_at = 0; + for (size_t at = 0; at < history.size(); ++at) { + points += scalar(px(at)) + "," + scalar(py(history[at])) + " "; + if (history[at] > history[high_at]) high_at = at; + if (history[at] < history[low_at]) low_at = at; + if (at >= 4) { + double sum = 0; + for (size_t back = 0; back < 5; ++back) sum += history[at - back]; + average += scalar(px(at)) + "," + scalar(py(sum / 5)) + " "; + } + } + svg += ""; + double mean = 0, spread = 0; + for (const double value : history) mean += value; + mean /= double(history.size()); + for (const double value : history) spread += (value - mean) * (value - mean); + spread = mean > 0 ? std::sqrt(spread / double(history.size())) * 100.0 / mean : 0; + const double trend = history.front() > 0 ? (history.back() - history.front()) * 100.0 / history.front() : 0; + const double below = hi > 0 ? (hi - history.back()) * 100.0 / hi : 0; + const auto held = finance.at("stocks")[size_t(bank_stock_)].get(); + const auto tile = [](const std::string &label, const std::string &value, const char *tone = "") { + return "
" + value + "" + label + "
"; + }; + out += "
()) + "\">" + picture(renderer_.diagram("bank-stock", svg, 1840), 920, 500) + "
" + "
KursFünf-Tage-SchnittHochTief
" + "
" + + tile("Hoch", number(int64_t(std::llround(hi)))) + tile("Tief", number(int64_t(std::llround(lo)))) + + tile(std::to_string(history.size()) + " Tage", (trend > 0 ? "+" : trend < 0 ? "−" : "") + one(std::abs(trend)) + " %", trend > 0.05 ? "up" : trend < -0.05 ? "down" : "") + + tile("Schwankung", one(spread) + " %") + tile("Depotwert", esc(bank_money(held * chosen.at("price").get()))) + + (chosen.contains("maxToBuy") ? tile("Kaufbar", number(chosen.at("maxToBuy").get())) : tile("Bestand", number(held))) + "
" + "

Analyse

" + + std::string(trend > 5 ? "Aufwärtstrend: " : trend < -5 ? "Abwärtstrend: " : "Seitwärtsbewegung: ") + "über " + std::to_string(history.size()) + " Tage " + + (trend > 0 ? "+" : trend < 0 ? "−" : "") + one(std::abs(trend)) + " %. " + + (below < 0.5 ? "Der Kurs steht am Hoch dieses Zeitraums." : "Der Kurs liegt " + one(below) + " % unter dem Hoch dieses Zeitraums.") + " " + + (spread > 12 ? "Das Papier schwankt stark." : spread > 5 ? "Das Papier schwankt mäßig." : "Das Papier läuft ruhig.") + "

"; + (void)price; + } else out += "

Für dieses Papier liegt noch kein Kursverlauf vor.

"; + out += "
" + actions("Kaufen", "stock-buy", "Verkaufen", "stock-sell"); } else if (bank_view_ == "credit") { if (engine_mode_) return out + engine_credit_view() + "
"; - out += "

Kredit

" + img("art.bank-adviser-v1.png", 620, 515, false, false, 1000) + + out += "
" + img("art.bank-adviser-v1.png", 620, 515, false, false, 1000) + "
"; const auto fact = [&](const char *label, const std::string &value, int row) { constexpr std::array y{0, 83, 166, 273, 356}; @@ -116,16 +244,13 @@ std::string App::render_bank() { fact("Maximaler Kredit", esc(bank_money(5000000 * finance_currency_factor(*world_))), 4) + "
"; const int term = finance.at("term"); const auto principal = summary.at("schedule_principal").get(); - const auto color = theme_ == "silver" ? "#233443" : theme_ == "matchday" ? "#efeded" : "#a8c0cf"; - const auto accent = theme_ == "silver" ? "#25617a" : theme_ == "matchday" ? "#efb2aa" : "#a9dfd1"; - const auto grid_color = theme_ == "silver" ? "#58738c38" : "#b7d0de24"; std::string svg = "" - "" - ""; + "" + ""; for (int i = 0; i < 5; ++i) { const auto y = 30 + i * 77.5; - svg += "" - "" + + svg += "" + "" + esc(bank_money((principal * (4 - i) + 2) / 4)) + ""; } const int interval = term <= 12 ? 3 : term <= 24 ? 6 : 12; @@ -134,15 +259,15 @@ std::string App::render_bank() { if (labels.back() != term) labels.push_back(term); for (const int month : labels) { svg += "" + (month == 0 ? "Heute" : std::to_string(month) + (month == term ? " Monate" : "")) + ""; } std::string points; for (const auto &point : summary.at("schedule")) points += scalar(220 + point.at("month").get() / term * 1960) + "," + scalar(340 - point.at("remaining").get() / principal * 310) + " "; svg += "" - ""; + line + "\" stroke-width=\"6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>" + ""; out += "

Restschuld über die Laufzeit

" + esc(bank_money(principal)) + " → " + esc(bank_money(0)) + "

" + std::to_string(term) + " Monate

" + (summary.at("schedule_example") == true ? "Beispiel · kein laufender Kredit" : "Aktueller Kredit") + @@ -151,23 +276,69 @@ std::string App::render_bank() { "

Gleichmäßige monatliche Tilgung · Restschuld ohne Zinsen

" "

Fiktiver Kredit. Im POC erfolgen keine Zins- oder Ratenbuchungen.

" + actions("Aufnehmen", "loan", "Tilgen", "repay"); } else if (bank_view_ == "overview") { - out += "

Finanzübersicht

"; - if (engine_mode_) { - const std::array, 5> fields{{{"Konto", "cash"}, {"Sparbuch", "deposit"}, {"Immobilien", "properties"}, {"Aktien", "stocks"}, {"Kreditlinie", "credit_line"}}}; - for (const auto &[label, key] : fields) { - const auto value = summary.at(key).get(); - out += "
" + std::string(label) + "" + esc(bank_money(value)) + "
"; - } - return out + "

Bestände und Kurse aus dem Spielstand · Kredite beim Bankberater.

"; + // where the money lies: a ring by share, the four places with their sums, and a reading of it + struct Part { const char *label; int64_t value; const char *colour; }; + const std::array parts{{{"Konto", std::max(0, in_cash), "#2f6f8f"}, {"Sparbuch", in_deposit, "#c9a24a"}, + {"Immobilien", in_property, "#6f8a52"}, {"Aktien", in_stock, "#a8574f"}}}; + const double around = 2 * 3.14159265358979 * 300; + std::string ring = ""; + double turned = 0; + for (const auto &part : parts) { + if (wealth <= 0 || part.value <= 0) continue; + const double length = around * double(part.value) / double(wealth); + if (part.value == wealth) { ring += ""; break; } + ring += ""; + turned += length; } - const std::array, 6> fields{{ - {"Konto", summary.at("cash")}, {"Sparbuch", summary.at("deposit")}, - {"Immobilien", summary.at("properties")}, {"Aktien", summary.at("stocks")}, - {"Kredit", -summary.at("debt").get()}, {"Saldo", summary.at("net")}}}; - for (size_t i = 0; i < fields.size(); ++i) - out += "
" + - fields[i].first + "" + (i == 4 ? "-" + esc(bank_money(summary.at("debt").get())) : esc(bank_money(fields[i].second))) + "
"; - out += "

Erfundene Bestände · Änderungen betreffen ausschließlich die Bankvorschau.

"; + ring += ""; + out += "
" + picture(renderer_.diagram("bank-ring", ring, 1600), 860, 860) + "
Vermögen" + + esc(bank_money(wealth)) + "
"; + const Part *largest = &parts[0]; + for (const auto &part : parts) { + if (part.value > largest->value) largest = ∂ + const double width = wealth > 0 ? std::max(0, part.value) * 100.0 / wealth : 0; + out += "
" + part.label + + "" + esc(bank_money(std::string(part.label) == "Konto" ? in_cash : part.value)) + "" + share(part.value) + + "
"; + } + if (engine_mode_) + out += "
Kreditlinie" + + esc(bank_money(summary.at("credit_line").get())) + "
"; + else + out += "
Kredit−" + + esc(bank_money(summary.at("debt").get())) + "
" + "
Saldo" + + esc(bank_money(summary.at("net").get())) + "
"; + out += "

Analyse

"; + if (wealth > 0) { + const int64_t invested = in_deposit + in_property + in_stock; + out += "Größter Posten: " + std::string(largest->label) + " mit " + share(largest->value) + " des Vermögens. " + + (invested > 0 ? "Angelegt in Sparbuch, Immobilien und Aktien sind " + share(invested) + "." + : std::string("Bisher ist nichts angelegt: Das ganze Vermögen liegt auf dem Konto.")); + } else out += "Es ist kein Vermögen vorhanden."; + out += "

"; + // the market at a glance: every stock's change over its recorded days + std::vector> market; + double widest = 1; + for (int i = 0; i < stock_count; ++i) { + const auto history = course(i); + if (history.size() < 2 || history.front() <= 0) continue; + const double change = (history.back() - history.front()) * 100.0 / history.front(); + market.emplace_back(assets.at("stocks")[size_t(i)].at("name").get(), change); + widest = std::max(widest, std::abs(change)); + } + if (!market.empty()) { + out += "

Aktienmarkt · Veränderung über die aufgezeichneten Tage

"; + for (const auto &[name, change] : market) { + const double height = std::abs(change) / widest * 120; + out += "
" + (change > 0 ? "+" + one(change) + " %
" : std::string()) + + "
" + (change <= 0 ? "
−" + one(std::abs(change)) + " %" : std::string()) + + "
" + esc(name) + "
"; + } + out += "
"; + } + out += "

" + std::string(engine_mode_ ? "Bestände und Kurse aus dem Spielstand." : "Erfundene Bestände · Änderungen betreffen ausschließlich die Bankvorschau.") + "

"; } return out + ""; } diff --git a/src/modern/ui/engine_balance.inc b/src/modern/ui/engine_balance.inc index 13137a6..18821a4 100644 --- a/src/modern/ui/engine_balance.inc +++ b/src/modern/ui/engine_balance.inc @@ -53,7 +53,7 @@ void App::engine_balance_preview(const EngineReply &reply) { engine_balance_base_ = read; balance_future_ = true; engine_balance_feedback_ = engine_balance_edits_.empty() - ? "Prognose der Engine für zwölf Monate." + ? "Prognose für zwölf Monate." : "Planentwurf · Noch nicht übernommen."; focus_after_render_ = "balance-toggle"; } diff --git a/src/modern/ui/engine_finance.inc b/src/modern/ui/engine_finance.inc index d127c7a..ed13446 100644 --- a/src/modern/ui/engine_finance.inc +++ b/src/modern/ui/engine_finance.inc @@ -98,22 +98,44 @@ bool App::engine_bank_action(const std::string &action, Rml::Element *target) { open_amount(std::move(request)); return true; } std::string App::engine_credit_view() { - std::string out = "

Kredit

" + img("art.bank-adviser-v1.png", 620, 515, false, false, 1000) + "
"; + std::string out = "
" + img("art.bank-adviser-v1.png", 620, 515, false, false, 1000) + "
"; Json data; try { data = engine_credit_projection(engine_data_, engine_credit_); } catch (const std::exception &) { return out + "

Der Bankkredit ist in diesem Kontext nicht verfügbar.

"; } - out += "
"; + // the original's labels arrive in capitals: one capital per word reads calmer + const auto calm = [](std::string text) { + bool first = true; + for (size_t i = 0; i < text.size(); ++i) { + const unsigned char c = static_cast(text[i]); + if (c == 0xc3 && i + 1 < text.size()) { + unsigned char next = static_cast(text[i + 1]); + if (!first && (next == 0x84 || next == 0x96 || next == 0x9c)) text[i + 1] = static_cast(next + 0x20); + ++i; first = false; + } else if (std::isalpha(c)) { if (!first) text[i] = static_cast(std::tolower(c)); first = false; } + else if (c == ' ' || c == '-') first = true; + } + return text; + }; + out += "
"; + int64_t total = 0, paid = 0; for (size_t i = 0; i < 8; ++i) { const auto &f = data.at("fields")[i]; const auto value = f.at("value").get(); + if (i == 1) total = value; + if (i == 5) paid = value; const auto text = i == 3 || i == 4 ? number(value) + " Monate" : money(value * 100, {{"code", "EUR"}, {"minor_units", 2}}); - out += "
" + esc(engine_text(f.at("label"))) + ""; - if (data.at("saved")[0] == 0 && f.at("editable") == true) out += btn("engine-credit-edit", esc(text), "bank-control", "id=\"engine-credit-" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\" style=\"width:780dp;height:56dp;font-size:30dp;\""); + out += "
" + esc(calm(engine_text(f.at("label")))) + ""; + if (data.at("saved")[0] == 0 && f.at("editable") == true) out += btn("engine-credit-edit", esc(text), "bank-control", "id=\"engine-credit-" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\""); else out += esc(text); out += "
"; } - out += "

Kreditvorschau

"; - out += "

Gebühren: " + esc(engine_price(data.at("fees"))) + "

Erstattung: " + esc(engine_price(data.at("refund"))) + "

Bereits getilgter Betrag: " + esc(engine_price(data.at("principalPaid"))) + "

"; - out += "

" + std::string(data.at("saved")[0] == 0 ? "Die Engine berechnet Laufzeit, Raten und Gebühren. Änderungen erst nach Bestätigung." : "Laufender Kredit · Änderungen folgen mit vollständiger Gebührenvorschau.") + "

"; + out += "

Kreditvorschau

"; + for (const auto &[label, key] : std::array, 3>{{{"Gebühren", "fees"}, {"Erstattung", "refund"}, {"Bereits getilgt", "principalPaid"}}}) + out += "
" + esc(engine_price(data.at(key))) + "" + label + "
"; + // how much of the whole sum is paid back + const double done = total > 0 ? std::clamp(double(paid) * 100.0 / double(total), 0.0, 100.0) : 0; + out += "
Zurückgezahlt" + (total > 0 ? std::to_string(int(std::lround(done))) + " %" : std::string("kein Kredit")) + + "
"; + out += "

" + std::string(data.at("saved")[0] == 0 ? "Die Bank berechnet Laufzeit, Raten und Gebühren. Gebucht wird erst nach deiner Bestätigung." : "Laufender Kredit · Änderungen folgen mit vollständiger Gebührenvorschau.") + "

"; out += ""; return out; } diff --git a/src/modern/ui/transfer_screens.inc b/src/modern/ui/transfer_screens.inc index 2ce24ce..4c59d84 100644 --- a/src/modern/ui/transfer_screens.inc +++ b/src/modern/ui/transfer_screens.inc @@ -552,7 +552,7 @@ std::string App::render_transfer_dialog() { std::to_string(i) + "\"") + "
"; body += "

" + - std::string(engine_mode_ ? "Die Engine entscheidet nach Bestätigung über dieses Angebot. Die Konditionen werden erst beim Absenden verbindlich." : mine ? "Der Spieler wird zum " + + std::string(engine_mode_ ? "Über das Angebot wird nach deiner Bestätigung entschieden. Die Konditionen werden erst beim Absenden verbindlich." : mine ? "Der Spieler wird zum " + std::string(loan ? "Verleihen" : "Verkauf") + " auf dem Markt vorgemerkt." : "Das Angebot wird vorgemerkt; die Entscheidung "