Ziel-Karte am Handy: schlanke Zeile, weicht Ton-Knopf aus, quer klein
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -262,7 +262,11 @@
|
||||
breit; bei der Mindestgröße (16 px, damit die kleinste Schrift
|
||||
11,5 px bleibt) wären das 320 Punkte -- auf einer 390er
|
||||
Leinwand mehr als drei Viertel des Bildes. */
|
||||
const klein = w > 0 && w < 560;
|
||||
/* UND UNTER 420 PUNKTEN HOEHE: Am Handy quer ist die Leinwand 844
|
||||
breit, aber nur gut 300 hoch -- die volle Karte bedeckte dort
|
||||
30 % des Spiels (gemessen 27.10.2026). */
|
||||
const hoch = kasten.clientHeight || 0;
|
||||
const klein = (w > 0 && w < 560) || (hoch > 0 && hoch < 420);
|
||||
wurzel.dataset.klein = klein ? 'ja' : 'nein';
|
||||
const basis = klein ? 14.4 : Math.max(16, Math.min(20, w * 0.0185));
|
||||
wurzel.style.fontSize = `${(basis * (klein ? Math.max(1, g) : g)).toFixed(2)}px`;
|
||||
@@ -297,48 +301,72 @@
|
||||
Quelle weiß niemand, was die Szene sonst noch zeigt. */
|
||||
function platzieren() {
|
||||
if (!opt.hindernisse) return;
|
||||
const oben = (wurzel.dataset.platz || 'or')[0] === 'o';
|
||||
if (wurzel.dataset.an !== 'ja') return;
|
||||
/* Die Wahl der Regie steht in `data-wunsch`; `data-platz` ist die
|
||||
Ecke, in der die Karte gerade WIRKLICH steht. Jeder Durchgang
|
||||
rechnet vom Wunsch aus -- so springt nichts hin und her. */
|
||||
const wunsch = wurzel.dataset.wunsch || wurzel.dataset.platz || 'or';
|
||||
const block = (wurzel.offsetParent || kasten).getBoundingClientRect();
|
||||
/* Die SICHTBARE Karte zählt, nicht das Rasterfeld -- das ist im
|
||||
Wechsel so breit wie die breiteste aller Karten. */
|
||||
const wr = (wurzel.querySelector('.szk[data-sichtbar="ja"]') || wurzel).getBoundingClientRect();
|
||||
if (block.width < 1 || wr.width < 1) return;
|
||||
const rand = (parseFloat(wurzel.style.fontSize) || 16) * 1.1;
|
||||
const rechts = (wurzel.dataset.platz || 'or')[1] === 'r';
|
||||
const luft = 6;
|
||||
const rechts = wunsch[1] === 'r';
|
||||
const x0 = rechts ? block.right - rand - wr.width : block.left + rand;
|
||||
const x1 = x0 + wr.width;
|
||||
const mitte = block.top + block.height / 2;
|
||||
let bedarf = rand;
|
||||
const H = block.height;
|
||||
const h = wr.height;
|
||||
/* Was in der Spalte der Karte liegt, in Koordinaten der Leinwand. */
|
||||
const im = [];
|
||||
for (const sel of opt.hindernisse) {
|
||||
for (const h of document.querySelectorAll(sel)) {
|
||||
if (wurzel.contains(h) || h.contains(wurzel)) continue;
|
||||
const r = h.getBoundingClientRect();
|
||||
for (const el of document.querySelectorAll(sel)) {
|
||||
if (wurzel.contains(el) || el.contains(wurzel)) continue;
|
||||
const r = el.getBoundingClientRect();
|
||||
if (r.width < 2 || r.height < 2) continue;
|
||||
const c = getComputedStyle(h);
|
||||
const c = getComputedStyle(el);
|
||||
if (c.visibility === 'hidden' || Number(c.opacity) < 0.05) continue;
|
||||
if (r.right < x0 - 8 || r.left > x1 + 8) continue;
|
||||
/* ZU WELCHER HÄLFTE ein Hindernis gehört, sagt seine MITTE --
|
||||
nicht seine Kante. Am Handy ragt „Ton einschalten" knapp über
|
||||
die Bildmitte; nach der Kante zählte es oben mit, die Karte
|
||||
passte rechnerisch nicht mehr und blieb unter dem Schild
|
||||
liegen (gemessen am 390er Handy). */
|
||||
const hMitte = (r.top + r.bottom) / 2;
|
||||
if (oben) {
|
||||
if (hMitte > mitte) continue;
|
||||
bedarf = Math.max(bedarf, r.bottom - block.top + 8);
|
||||
} else {
|
||||
if (hMitte < mitte) continue;
|
||||
bedarf = Math.max(bedarf, block.bottom - r.top + 8);
|
||||
}
|
||||
im.push({ oben: r.top - block.top, unten: r.bottom - block.top });
|
||||
}
|
||||
}
|
||||
const passt = bedarf + wr.height <= block.height - rand;
|
||||
const wert = `${Math.round(passt ? bedarf : rand)}px`;
|
||||
wurzel.dataset.gedraengt = passt ? 'nein' : 'ja';
|
||||
const name = oben ? '--sz-oben' : '--sz-unten';
|
||||
/* ==== ZWEI GRENZEN, NICHT EINE (27.10.2026, am Handy gemessen) ===
|
||||
Bisher schob nur, was in der EIGENEN Hälfte lag. Am Handy steht
|
||||
„Ton einschalten" mitten im Bild -- die Karte rutschte unter dem
|
||||
Schild hervor und genau auf diesen Knopf. Jetzt gilt: Was in der
|
||||
eigenen Hälfte liegt, schiebt den Anfang; was in der anderen
|
||||
liegt, begrenzt das Ende. ZU WELCHER HÄLFTE ein Hindernis gehört,
|
||||
sagt weiter seine MITTE, nicht seine Kante.
|
||||
`start` ist der Abstand vom eigenen Rand (oben oder unten). */
|
||||
const versuch = (oben) => {
|
||||
let start = rand;
|
||||
let grenze = H - rand;
|
||||
for (const o of im) {
|
||||
const eigene = oben ? (o.oben + o.unten) / 2 <= H / 2 : (o.oben + o.unten) / 2 >= H / 2;
|
||||
if (eigene) start = Math.max(start, oben ? o.unten + luft : H - o.oben + luft);
|
||||
else grenze = Math.min(grenze, oben ? o.oben - luft : H - o.unten - luft);
|
||||
}
|
||||
return { oben, start, passt: start + h <= grenze };
|
||||
};
|
||||
/* Passt sie in ihrer Hälfte nicht, darf sie in die andere -- in
|
||||
derselben Ecke links oder rechts. Passt sie nirgends, bleibt sie
|
||||
im Wunsch, aber UNTER dem, was oben liegt (das Schild steht
|
||||
höher als sie und deckte sonst ihren Titel), und sagt es. */
|
||||
const wunschOben = wunsch[0] === 'o';
|
||||
let v = versuch(wunschOben);
|
||||
if (!v.passt) {
|
||||
const anders = versuch(!wunschOben);
|
||||
if (anders.passt) v = anders;
|
||||
}
|
||||
const platz = (v.oben ? 'o' : 'u') + wunsch[1];
|
||||
if (wurzel.dataset.platz !== platz) wurzel.dataset.platz = platz;
|
||||
wurzel.dataset.gewichen = v.oben === wunschOben ? 'nein' : 'ja';
|
||||
wurzel.dataset.gedraengt = v.passt ? 'nein' : 'ja';
|
||||
const wert = `${Math.round(Math.max(rand, Math.min(v.start, H - rand - h)))}px`;
|
||||
const name = v.oben ? '--sz-oben' : '--sz-unten';
|
||||
if (wurzel.style.getPropertyValue(name) !== wert) wurzel.style.setProperty(name, wert);
|
||||
wurzel.style.removeProperty(oben ? '--sz-unten' : '--sz-oben');
|
||||
wurzel.style.removeProperty(v.oben ? '--sz-unten' : '--sz-oben');
|
||||
}
|
||||
/* ==== DIE VORSCHAU WIRD EINGEPASST, NICHT KLEINER GERECHNET ======
|
||||
Die Regie-Spalte ist schmaler als die Karte (320 Punkte). Kleiner
|
||||
@@ -402,7 +430,11 @@
|
||||
const vorherAnzeige = stand?.anzeige;
|
||||
const vorherWechsel = stand?.wechsel_s;
|
||||
stand = neu;
|
||||
wurzel.dataset.platz = ['ol', 'or', 'ul', 'ur'].includes(neu.platz) ? neu.platz : 'or';
|
||||
const wunsch = ['ol', 'or', 'ul', 'ur'].includes(neu.platz) ? neu.platz : 'or';
|
||||
if (wurzel.dataset.wunsch !== wunsch || !wurzel.dataset.platz) {
|
||||
wurzel.dataset.wunsch = wunsch;
|
||||
wurzel.dataset.platz = wunsch;
|
||||
}
|
||||
masse();
|
||||
|
||||
const ziele = Array.isArray(neu.ziele) ? neu.ziele : [];
|
||||
|
||||
Reference in New Issue
Block a user