Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- ui/gradio_app.py +0 -29
- ui/interface.py +5 -4
ui/gradio_app.py
CHANGED
|
@@ -297,35 +297,6 @@ def _safe_pos(position):
|
|
| 297 |
return (max(0, min(2, int(x))), max(0, min(2, int(y))))
|
| 298 |
|
| 299 |
|
| 300 |
-
# --- polling helpers ---
|
| 301 |
-
def _get_scene_html():
|
| 302 |
-
"""Return forest_scene HTML using a shallow copy of STATE."""
|
| 303 |
-
with _STATE_LOCK:
|
| 304 |
-
state_copy = copy.deepcopy(STATE)
|
| 305 |
-
state_for_renderer = {
|
| 306 |
-
"active_mushrooms": state_copy.get("active_mushrooms", []),
|
| 307 |
-
"score_total": state_copy.get("score_total", 0),
|
| 308 |
-
"health": state_copy.get("health", 3),
|
| 309 |
-
"event_emoji": "✨",
|
| 310 |
-
"event_title": state_copy.get("thought", ""),
|
| 311 |
-
"mystery_title": "The Wrong Memory",
|
| 312 |
-
"picked": "No",
|
| 313 |
-
"game_over": "No",
|
| 314 |
-
}
|
| 315 |
-
return forest_scene(state_for_renderer, state_copy.get("collection", []), state_copy.get("position"))
|
| 316 |
-
|
| 317 |
-
def poll_scene():
|
| 318 |
-
"""Bound to the scene HTML component via demo.load."""
|
| 319 |
-
return _get_scene_html()
|
| 320 |
-
|
| 321 |
-
def poll_myco_bubble_html():
|
| 322 |
-
"""Return the HTML for the Myco speech bubble (cleaned)."""
|
| 323 |
-
with _STATE_LOCK:
|
| 324 |
-
raw = STATE.get("thought", "")
|
| 325 |
-
# myco_talking_markdown will parse/clean raw blocks or plain text
|
| 326 |
-
return myco_talking_markdown(raw)
|
| 327 |
-
|
| 328 |
-
|
| 329 |
GUIDE_MARKDOWN = """
|
| 330 |
## How to play
|
| 331 |
|
|
|
|
| 297 |
return (max(0, min(2, int(x))), max(0, min(2, int(y))))
|
| 298 |
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
GUIDE_MARKDOWN = """
|
| 301 |
## How to play
|
| 302 |
|
ui/interface.py
CHANGED
|
@@ -197,10 +197,10 @@ def render_shroom_tab():
|
|
| 197 |
thought_html = gr.HTML() # use HTML so markup is not escaped
|
| 198 |
dex_md = gr.Markdown()
|
| 199 |
|
| 200 |
-
# Bind polling: update scene and thought periodically
|
| 201 |
-
#
|
| 202 |
-
gr.load(fn=
|
| 203 |
-
gr.load(fn=
|
| 204 |
|
| 205 |
# Optional: dex button
|
| 206 |
def show_dex():
|
|
@@ -214,4 +214,5 @@ def render_shroom_tab():
|
|
| 214 |
# Return components if needed
|
| 215 |
return scene_html, thought_html, dex_md
|
| 216 |
|
|
|
|
| 217 |
|
|
|
|
| 197 |
thought_html = gr.HTML() # use HTML so markup is not escaped
|
| 198 |
dex_md = gr.Markdown()
|
| 199 |
|
| 200 |
+
# Bind polling: update scene and thought periodically (inline lambdas avoid NameError)
|
| 201 |
+
# These lambdas call helpers that should be defined/imported earlier in the module.
|
| 202 |
+
gr.load(fn=lambda: _get_scene_html(), outputs=scene_html, every=1.5)
|
| 203 |
+
gr.load(fn=lambda: myco_talking_markdown(STATE.get("thought", "")), outputs=thought_html, every=1.5)
|
| 204 |
|
| 205 |
# Optional: dex button
|
| 206 |
def show_dex():
|
|
|
|
| 214 |
# Return components if needed
|
| 215 |
return scene_html, thought_html, dex_md
|
| 216 |
|
| 217 |
+
|
| 218 |
|