Spaces:
Sleeping
Sleeping
Commit ·
e875da4
1
Parent(s): b828605
fix(game): diegetic tone class on #game-view so the world tints
Browse files- app.py +16 -0
- render.py +5 -0
- styles.css +13 -11
app.py
CHANGED
|
@@ -423,7 +423,23 @@ _HEAD_JS = """
|
|
| 423 |
|
| 424 |
// mute button + restart + mode buttons, wired once rendered
|
| 425 |
function icon() { return st.muted ? '\\uD83D\\uDD07' : '\\uD83D\\uDD0A'; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
function wire() {
|
|
|
|
| 427 |
// corner drawers: header chip toggles expand
|
| 428 |
document.querySelectorAll('.game-drawer .drawer-head').forEach(function (h) {
|
| 429 |
if (h.dataset.hollowWired) return;
|
|
|
|
| 423 |
|
| 424 |
// mute button + restart + mode buttons, wired once rendered
|
| 425 |
function icon() { return st.muted ? '\\uD83D\\uDD07' : '\\uD83D\\uDD0A'; }
|
| 426 |
+
// lift the per-turn tone onto #game-view so the WORLD tints (the marker
|
| 427 |
+
// .tone-now lives inside #game-entity, a sibling of #game-bg/#game-vig)
|
| 428 |
+
function applyTone() {
|
| 429 |
+
var gv = document.getElementById('game-view');
|
| 430 |
+
var mark = document.querySelector('#game-view .tone-now[data-tone]');
|
| 431 |
+
if (!gv || !mark) return;
|
| 432 |
+
var t = mark.getAttribute('data-tone');
|
| 433 |
+
if (gv.dataset.tone === t) return;
|
| 434 |
+
gv.dataset.tone = t;
|
| 435 |
+
['tone-warm','tone-neutral','tone-wounded','tone-hostile'].forEach(function (c) {
|
| 436 |
+
gv.classList.remove(c);
|
| 437 |
+
});
|
| 438 |
+
gv.classList.add('tone-' + t);
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
function wire() {
|
| 442 |
+
applyTone();
|
| 443 |
// corner drawers: header chip toggles expand
|
| 444 |
document.querySelectorAll('.game-drawer .drawer-head').forEach(function (h) {
|
| 445 |
if (h.dataset.hollowWired) return;
|
render.py
CHANGED
|
@@ -300,7 +300,12 @@ def render_entity(affinity: int, mode: str = "idle", seq: int = 0,
|
|
| 300 |
# text streams — the chime was redundant feedback and, with streaming,
|
| 301 |
# fired out of sync (at stream start, then again at the end).
|
| 302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
return (
|
|
|
|
| 304 |
f'<div class="entity-scene {tone_class}">'
|
| 305 |
f'{figure}{flash}{tint}'
|
| 306 |
'</div>'
|
|
|
|
| 300 |
# text streams — the chime was redundant feedback and, with streaming,
|
| 301 |
# fired out of sync (at stream start, then again at the end).
|
| 302 |
|
| 303 |
+
# tone-now marker: a head-JS MutationObserver reads data-tone and lifts the
|
| 304 |
+
# tone class onto #game-view (the common ancestor of #game-bg/#game-vig/
|
| 305 |
+
# #game-scene) so the whole world tints, not just this panel's silhouette.
|
| 306 |
+
tone_token = tone_class.split("-", 1)[1] if "-" in tone_class else "neutral"
|
| 307 |
return (
|
| 308 |
+
f'<span class="tone-now" data-tone="{tone_token}" style="display:none"></span>'
|
| 309 |
f'<div class="entity-scene {tone_class}">'
|
| 310 |
f'{figure}{flash}{tint}'
|
| 311 |
'</div>'
|
styles.css
CHANGED
|
@@ -1693,34 +1693,36 @@ footer { display: none !important; }
|
|
| 1693 |
overflow: hidden !important;
|
| 1694 |
}
|
| 1695 |
|
| 1696 |
-
/* tone classes — the world blooms or rots
|
| 1697 |
-
|
| 1698 |
-
|
|
|
|
|
|
|
| 1699 |
background:
|
| 1700 |
radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(4,3,8,0.45) 100%),
|
| 1701 |
linear-gradient(to bottom, rgba(6,4,12,0.28) 0%, transparent 13%);
|
| 1702 |
}
|
| 1703 |
-
.tone-warm .entity-img { filter: brightness(1.12) drop-shadow(0 0 18px rgba(190,170,220,0.30)) !important; }
|
| 1704 |
|
| 1705 |
-
.tone-neutral #game-bg { filter: grayscale(1) blur(38px) brightness(0.52); }
|
| 1706 |
|
| 1707 |
-
.tone-wounded #game-bg { filter: grayscale(1) blur(38px) brightness(0.38); }
|
| 1708 |
-
.tone-wounded #game-vig {
|
| 1709 |
background:
|
| 1710 |
radial-gradient(ellipse at 50% 42%, transparent 38%, rgba(4,3,8,0.78) 100%),
|
| 1711 |
linear-gradient(to bottom, rgba(6,4,12,0.65) 0%, transparent 13%);
|
| 1712 |
}
|
| 1713 |
-
.tone-wounded .entity-img { opacity: 0.85 !important; }
|
| 1714 |
|
| 1715 |
-
.tone-hostile #game-bg {
|
| 1716 |
filter: grayscale(1) blur(38px) brightness(0.30);
|
| 1717 |
}
|
| 1718 |
-
.tone-hostile #game-vig {
|
| 1719 |
background:
|
| 1720 |
radial-gradient(ellipse at 50% 42%, transparent 32%, rgba(30,4,8,0.80) 100%),
|
| 1721 |
linear-gradient(to bottom, rgba(40,6,12,0.52) 0%, transparent 20%);
|
| 1722 |
}
|
| 1723 |
-
.tone-hostile .entity-img {
|
| 1724 |
filter: sepia(0.22) saturate(1.35) brightness(0.95) drop-shadow(0 0 18px rgba(120,40,40,0.35)) !important;
|
| 1725 |
}
|
| 1726 |
|
|
|
|
| 1693 |
overflow: hidden !important;
|
| 1694 |
}
|
| 1695 |
|
| 1696 |
+
/* tone classes — the world blooms or rots. Scoped under #game-view: the
|
| 1697 |
+
tone token is lifted onto #game-view by the head JS (applyTone), so #game-bg
|
| 1698 |
+
/#game-vig (siblings of #game-entity) actually tint. */
|
| 1699 |
+
#game-view.tone-warm #game-bg { filter: grayscale(1) blur(38px) brightness(0.62); }
|
| 1700 |
+
#game-view.tone-warm #game-vig {
|
| 1701 |
background:
|
| 1702 |
radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(4,3,8,0.45) 100%),
|
| 1703 |
linear-gradient(to bottom, rgba(6,4,12,0.28) 0%, transparent 13%);
|
| 1704 |
}
|
| 1705 |
+
#game-view.tone-warm .entity-img { filter: brightness(1.12) drop-shadow(0 0 18px rgba(190,170,220,0.30)) !important; }
|
| 1706 |
|
| 1707 |
+
#game-view.tone-neutral #game-bg { filter: grayscale(1) blur(38px) brightness(0.52); }
|
| 1708 |
|
| 1709 |
+
#game-view.tone-wounded #game-bg { filter: grayscale(1) blur(38px) brightness(0.38); }
|
| 1710 |
+
#game-view.tone-wounded #game-vig {
|
| 1711 |
background:
|
| 1712 |
radial-gradient(ellipse at 50% 42%, transparent 38%, rgba(4,3,8,0.78) 100%),
|
| 1713 |
linear-gradient(to bottom, rgba(6,4,12,0.65) 0%, transparent 13%);
|
| 1714 |
}
|
| 1715 |
+
#game-view.tone-wounded .entity-img { opacity: 0.85 !important; }
|
| 1716 |
|
| 1717 |
+
#game-view.tone-hostile #game-bg {
|
| 1718 |
filter: grayscale(1) blur(38px) brightness(0.30);
|
| 1719 |
}
|
| 1720 |
+
#game-view.tone-hostile #game-vig {
|
| 1721 |
background:
|
| 1722 |
radial-gradient(ellipse at 50% 42%, transparent 32%, rgba(30,4,8,0.80) 100%),
|
| 1723 |
linear-gradient(to bottom, rgba(40,6,12,0.52) 0%, transparent 20%);
|
| 1724 |
}
|
| 1725 |
+
#game-view.tone-hostile .entity-img {
|
| 1726 |
filter: sepia(0.22) saturate(1.35) brightness(0.95) drop-shadow(0 0 18px rgba(120,40,40,0.35)) !important;
|
| 1727 |
}
|
| 1728 |
|