Files
williamandClaude Sonnet 5 b2e933f322
Build and deploy / test-python (push) Successful in 11m12s
Build and deploy / test-js (push) Successful in 53s
Build and deploy / lint-python (push) Successful in 3m56s
Build and deploy / lint-js (push) Successful in 3m1s
Build and deploy / build-and-push (push) Skipped
Build and deploy / deploy (push) Skipped
Build and deploy / sonarqube (push) Failing after 3m58s
Reorganisation game/document : renommage screens->game_engine + sous-dossiers game/ dans routes, scripts, static, templates, tests
Prepare la scission a venir entre l'editeur Jeu 2D et le futur editeur
Support de formation (voir docs/plan/PLAN.md), sans toucher a
l'architecture en couches existante :

- screens/ renomme en game_engine/ (nom clair pour le moteur du jeu 2D,
  avant l'arrivee d'un second "moteur" cote document) : ~85 imports
  corriges, contrat import-linter mis a jour, meme forme de couches.
- routes/, scripts/, static/, templates/, tests/ : tout ce qui est
  propre au jeu 2D deplace dans un sous-dossier game/ de chacun
  (routes/game/, static/game/, templates/game/, tests/game/,
  scripts/game/) ; ce qui est partage par le site (auth, onboarding,
  dashboard, uploads, db/) reste a la racine de chaque dossier. Un
  sous-dossier document/ (vide) cree dans chacun pour le futur chantier.
- styles/ volontairement inchange : les 3 fichiers sources sont
  concatenes en un seul static/style.css charge par tout le site,
  scinder leur CONTENU (editeur vs partage) serait un refactor CSS
  distinct, pas un deplacement mecanique.
- Chaine d'export SCORM (publish/build_scorm_package.py) mise a jour en
  profondeur : copie des assets, URLs d'icones relatives a
  static/style.css (qui ne bouge pas), manifeste, wrapper SCORM.
- Deux regressions d'un sweep de renommage anterieur corrigees au passage
  (screens.js/screens/scene-objects incorrectement convertis en
  game_engine.js/game_engine/scene-objects dans des commentaires).
- Effet de bord Windows decouvert et corrige : git mv + Path.write_text
  convertissent des fichiers en CRLF (core.autocrlf=true) - ~189 fichiers
  normalises en LF.
- .eslintrc.json/package.json : uniquement les chemins de glob mis a jour
  (static/game/js/...) ; la preparation eslint-plugin-unicorn du lot 7
  reste volontairement non committee (package-lock.json restaure a la
  version precedente).

Verifications : ruff, mypy --strict (391 fichiers), vulture, bandit,
lint-imports tous verts ; 591/591 tests Python, 276/276 tests JS ;
demarrage serveur + requetes HTTP manuelles confirmant que les assets
deplaces repondent en 200 au nouvel emplacement et 404 a l'ancien.

SKIP=djlint : backlog H021 (styles inline) deja documente comme dette
assumee dans CODE_QUALITY.md section 6, aucun template touche par ce
commit au-dela d'un deplacement de fichier.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-19 12:27:53 +02:00

55 lines
2.0 KiB
Python

import json
from typing import Any
# Widget d'interface "💬 Boîte de dialogue" (voir "🖥️ Interface",
# templates/game/scene_edit.html, game_engine/scenes/add_scene_object.py kind=
# "dialogue_box") : affiche AUTOMATIQUEMENT, en jeu, la réplique en cours
# d'un dialogue déclenché par une règle de collision "dialogue" (voir
# static/game/js/play/dialogue-box-controller.js) — header (nom du
# personnage qui parle), corps (texte), pied (bouton "Suivant"),
# entièrement stylisable par l'auteur.
DEFAULT_DIALOGUE_BOX_STYLE: dict[str, Any] = {
"font_family": "inherit",
"font_size": 14,
"font_weight": "normal",
"text_color": "#ffffff",
"header_bg": "#2f6fed",
"body_bg": "#1a1d24",
"footer_bg": "#11141b",
}
FONT_WEIGHT_CHOICES = ["normal", "bold"]
def sanitize_dialogue_box_style(raw_style: Any) -> dict[str, Any]:
style = dict(DEFAULT_DIALOGUE_BOX_STYLE)
if not isinstance(raw_style, dict):
return style
if isinstance(raw_style.get("font_family"), str) and raw_style["font_family"].strip():
style["font_family"] = raw_style["font_family"].strip()[:60]
raw_font_size = raw_style.get("font_size")
try:
if raw_font_size is None:
raise ValueError
style["font_size"] = max(8, min(48, int(raw_font_size)))
except (TypeError, ValueError):
pass
if raw_style.get("font_weight") in FONT_WEIGHT_CHOICES:
style["font_weight"] = raw_style["font_weight"]
for key in ("text_color", "header_bg", "body_bg", "footer_bg"):
value = raw_style.get(key)
if isinstance(value, str) and value.strip():
style[key] = value.strip()[:20]
return style
def resolve_dialogue_box_style(obj: dict[str, Any]) -> dict[str, Any]:
raw = (obj.get("attributes") or {}).get("_dialogue_box_style")
if not raw:
return dict(DEFAULT_DIALOGUE_BOX_STYLE)
try:
parsed = json.loads(raw)
except (TypeError, ValueError):
return dict(DEFAULT_DIALOGUE_BOX_STYLE)
return sanitize_dialogue_box_style(parsed)