From 14ec76dddd9b5e06d8f49ec9db7e9f05d4683d9d Mon Sep 17 00:00:00 2001 From: william Date: Thu, 3 Sep 2026 16:55:09 +0200 Subject: [PATCH] =?UTF-8?q?=C3=89diteur=20:=20le=20canevas=20affiche=20tou?= =?UTF-8?q?t=20le=20monde=20(fond=20agrandi),=20pas=20que=20la=20sc=C3=A8n?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suite au fix du glisser figé à (0,0) : le canevas de l'éditeur restait malgré tout limité à la scène nominale (960×540 par ex.) — la partie d'un "fond" plus grand qui dépasse restait invisible/injoignable à la souris. Le canevas affiche désormais tout le "monde" (max de la scène et de l'étendue de chaque "fond", voir routes/scenes/scene_edit_view.py), comme la caméra en jeu le fait déjà (personnage-controller.js). Nouveau repère visuel "🎥 Champ de la caméra" : un cadre en pointillés marquant où s'arrête la scène nominale à l'intérieur de ce monde agrandi (le reste est assombri), pour que l'auteur voie clairement ce que le joueur verra réellement à l'écran une fois le monde plus grand que le viewport. Co-Authored-By: Claude Sonnet 5 --- routes/scenes/scene_edit_view.py | 19 +++++++++++++++++ static/style.css | 10 +++++++++ templates/scene_edit.html | 24 ++++++++++++++++++--- tests/test_scene_edit_view.py | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 3 deletions(-) diff --git a/routes/scenes/scene_edit_view.py b/routes/scenes/scene_edit_view.py index d4276a37..7ef00f2c 100644 --- a/routes/scenes/scene_edit_view.py +++ b/routes/scenes/scene_edit_view.py @@ -21,6 +21,24 @@ def render_scene_edit(slug, screen_id, game): objects = screens.list_scene_objects(slug, screen_id) for o in objects: o["rendered_html"] = screens.render_scene_object(o) + + # "Monde" (voir static/js/play/personnage-controller.js:: + # forgeUpdateSceneWorldSize, même principe côté serveur) : un "fond" + # posé à sa taille RÉELLE (souvent plus grande que la scène, voir + # add_scene_object.py) rend visible/joignable, dans CET éditeur, tout + # ce qui dépasse la scène nominale plutôt que de le rogner (le + # glisser-déposer le permet déjà depuis le fix précédent — sans + # agrandir le canevas ici, cette partie restait invisible/injoignable + # à la souris). Le rectangle "🎥 Champ de la caméra" (voir + # templates/scene_edit.html) marque ensuite où s'arrête la scène + # nominale À L'INTÉRIEUR de ce monde plus grand. + world_width, world_height = screen["scene_width"], screen["scene_height"] + for o in objects: + if o["kind"] == "fond": + world_width = max(world_width, o["x"] + o["width"]) + world_height = max(world_height, o["y"] + o["height"]) + world_width, world_height = int(world_width), int(world_height) + selected_id = request.args.get("selected", type=int) personnage_data = None personnage_commands = None @@ -95,6 +113,7 @@ def render_scene_edit(slug, screen_id, game): return render_template( "scene_edit.html", game=game, screen=screen, all_screens=all_screens, + world_width=world_width, world_height=world_height, objects=objects, selected_id=selected_id, personnage_data=personnage_data, personnage_commands=personnage_commands or screens.DEFAULT_PERSONNAGE_COMMANDS, personnage_role=personnage_role or screens.DEFAULT_PERSONNAGE_ROLE, diff --git a/static/style.css b/static/style.css index c8ec72c7..8b0ced04 100644 --- a/static/style.css +++ b/static/style.css @@ -592,6 +592,16 @@ body.builderBody > main.content{ flex:1 1 auto; min-height:0; overflow:hidden; d position:relative; width:100%; height:100%; flex:1 1 auto; margin:0; background:#0b0d12; border-radius:8px; overflow:hidden; border:1px solid var(--border); } +/* "🎥 Champ de la caméra" (voir templates/scene_edit.html) : repère + visuel marquant, à l'intérieur d'un monde agrandi par un "fond" plus + grand que la scène, les limites RÉELLES de ce que la caméra montre en + jeu — jamais interactif (pointer-events:none), pour ne jamais gêner la + sélection/le glisser d'un objet dessous. */ +.sceneCameraFrame{ + position:absolute; left:0; top:0; border:2px dashed var(--accent); + box-shadow:0 0 0 2000px rgba(0,0,0,.45); + pointer-events:none; z-index:5; +} .canvasElement{ /* Pas d'overflow:hidden ici : une échelle (transform:scale) ou une animation posée sur cet élément (voir la Timeline d'animation) vit sur diff --git a/templates/scene_edit.html b/templates/scene_edit.html index 90aa00c9..270308d1 100644 --- a/templates/scene_edit.html +++ b/templates/scene_edit.html @@ -121,7 +121,20 @@
-
+
+ {% if world_width > screen.scene_width or world_height > screen.scene_height %} + +
+ {% endif %} {% for o in objects %}
le monde affiché reste + exactement la scène nominale, et le repère "🎥 Champ de la caméra" + (voir static/style.css .sceneCameraFrame) ne s'affiche pas — inutile + tant que rien ne dépasse.""" + slug, screen_id = _create_jeu2d_game(client, tmp_game_slug_cleanup) + html = client.get(f"/game/{slug}/screens/{screen_id}/edit").get_data(as_text=True) + assert 'id="canvas" style="width:960px; height:540px;' in html + assert "sceneCameraFrame" not in html + + +def test_scene_edit_view_expands_world_for_an_oversized_fond(client, tmp_game_slug_cleanup): + """Bug corrigé (glisser-déposer figé à (0,0) pour un objet plus grand + que la scène, voir static/js/scenes/scene-editor.js) : le canevas de + l'éditeur doit maintenant afficher tout le "fond", pas seulement la + scène nominale (960×540) qu'il dépasse — sinon la partie qui dépasse + resterait invisible/injoignable à la souris malgré le fix du glisser.""" + slug, screen_id = _create_jeu2d_game(client, tmp_game_slug_cleanup) + fond_id = screens.add_scene_object(slug, screen_id, kind="fond") + screens.update_scene_object_geometry(slug, fond_id, x=0, y=0, width=1920, height=1080) + html = client.get(f"/game/{slug}/screens/{screen_id}/edit").get_data(as_text=True) + assert 'id="canvas" style="width:1920px; height:1080px;' in html + # Le repère de la caméra marque toujours les bornes de la scène NOMINALE (960×540), + # même si le canevas affiché est désormais bien plus grand. + assert 'class="sceneCameraFrame" style="width:960px; height:540px;' in html + + +def test_scene_edit_view_world_bounds_are_used_for_drag_clamping(client, tmp_game_slug_cleanup): + slug, screen_id = _create_jeu2d_game(client, tmp_game_slug_cleanup) + fond_id = screens.add_scene_object(slug, screen_id, kind="fond") + screens.update_scene_object_geometry(slug, fond_id, x=0, y=0, width=1920, height=1080) + html = client.get(f"/game/{slug}/screens/{screen_id}/edit").get_data(as_text=True) + assert "var SCENE_WIDTH = 1920;" in html + assert "var SCENE_HEIGHT = 1080;" in html