diff --git a/static/js/scenes/scene-editor.js b/static/js/scenes/scene-editor.js index 9fe057dc..3110058d 100644 --- a/static/js/scenes/scene-editor.js +++ b/static/js/scenes/scene-editor.js @@ -20,14 +20,16 @@ function addSceneObject(kind, forgeCharacter, backgroundSlug) { form.requestSubmit(); } -// "📐 Agrandir la camĂ©ra Ă  la zone visible" (voir templates/scene_edit.html) : -// fait de tout le "monde" affichĂ© par l'Ă©diteur (voir world_width/ -// world_height, routes/scenes/scene_edit_view.py — la taille rĂ©elle -// d'un "fond" plus grand que la scĂšne nominale) la scĂšne/camĂ©ra -// elle-mĂȘme — recharge la page ensuite, SCENE_WIDTH/SCENE_HEIGHT et le -// cadre "đŸŽ„ Champ de la camĂ©ra" doivent tous deux reflĂ©ter la nouvelle -// taille, plus simple qu'une mise Ă  jour partielle en JS. -function expandCameraToWorld(width, height) { +// Taille de la camĂ©ra (voir "🎼 Jeu 2D" en haut de templates/ +// scene_edit.html) — TOUJOURS modifiable ici, directement en pixels +// (demande explicite : "l'Ă©cran de l'Ă©diteur a une taille fixe, la +// camĂ©ra a la mĂȘme taille, c'est tout") : recharge la page une fois +// appliquĂ©, SCENE_WIDTH/SCENE_HEIGHT et le cadre "đŸŽ„ Champ de la camĂ©ra" +// Ă©ventuel doivent tous deux reflĂ©ter la nouvelle taille, plus simple +// qu'une mise Ă  jour partielle en JS. +function applyCameraSize() { + var wEl = document.getElementById('scene-camera-w'), hEl = document.getElementById('scene-camera-h'); + var width = parseInt(wEl.value, 10) || 1, height = parseInt(hEl.value, 10) || 1; fetch("/game/" + GAME_SLUG + "/screens/" + SCREEN_ID + "/scene-size", { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ width: width, height: height }), diff --git a/templates/scene_edit.html b/templates/scene_edit.html index fefc770c..c5d51b7e 100644 --- a/templates/scene_edit.html +++ b/templates/scene_edit.html @@ -30,15 +30,21 @@ demande de l'utilisateur, en prĂ©vision d'un Ă©diteur dĂ©diĂ© aux scĂšnes 2D (collision/pĂ©rimĂštre -> action), pas encore construit. -->

- 🎼 Jeu 2D — scùne à taille fixe ({{ screen.scene_width }}×{{ screen.scene_height }} px). - {% if world_width > screen.scene_width or world_height > screen.scene_height %} - - - {% endif %} + 🎼 Jeu 2D — scùne à taille fixe. + + + + +

diff --git a/tests/test_scene_edit_view.py b/tests/test_scene_edit_view.py index b653fd93..8a1e0781 100644 --- a/tests/test_scene_edit_view.py +++ b/tests/test_scene_edit_view.py @@ -214,6 +214,12 @@ def test_scene_edit_view_world_matches_scene_when_no_oversized_fond(client, tmp_ 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 + # "CamĂ©ra (px)" : TOUJOURS modifiable, mĂȘme sans fond qui dĂ©passe + # (demande explicite : "l'Ă©cran de l'Ă©diteur a une taille fixe, la + # camĂ©ra a la mĂȘme taille, c'est tout" — un rĂ©glage direct, pas + # seulement suggĂ©rĂ© automatiquement). + assert 'id="scene-camera-w" class="input is-small" style="width:80px;" min="1" value="960"' in html + assert 'id="scene-camera-h" class="input is-small" style="width:80px;" min="1" value="540"' in html def test_scene_edit_view_expands_world_for_an_oversized_fond(client, tmp_game_slug_cleanup): @@ -242,9 +248,9 @@ def test_scene_edit_view_world_bounds_are_used_for_drag_clamping(client, tmp_gam def test_set_scene_size_updates_screen_dimensions(tmp_game_slug_cleanup): - """"📐 Agrandir la camĂ©ra Ă  la zone visible" (voir templates/ - scene_edit.html) : fait du "monde" affichĂ© la scĂšne/camĂ©ra - elle-mĂȘme — jusqu'ici fixĂ©e Ă  la crĂ©ation et jamais modifiable.""" + """"CamĂ©ra (px)" (voir templates/scene_edit.html) : jusqu'ici + scene_width/scene_height n'Ă©taient fixĂ©es qu'Ă  la crĂ©ation de + l'Ă©cran, jamais modifiables ensuite.""" slug = tmp_game_slug_cleanup(db.create_game("pytest_scene_size")) screen_id = screens.create_screen(slug, "ScĂšne 1", kind="jeu_2d") screens.set_scene_size(slug, screen_id, 1920, 1080) @@ -262,9 +268,12 @@ def test_screen_set_scene_size_route_persists_and_reflects_in_editor(client, tmp assert resp.get_json() == {"ok": True} 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 - # La scĂšne nominale == le monde dĂ©sormais -> plus de repĂšre camĂ©ra ni de bouton. + # La scĂšne nominale == le monde dĂ©sormais -> plus de repĂšre camĂ©ra. assert "sceneCameraFrame" not in html - assert "Agrandir la camĂ©ra" not in html + # Les champs "CamĂ©ra (px)" restent TOUJOURS visibles (pas conditionnels), + # prĂ©-remplis avec la nouvelle taille. + assert 'id="scene-camera-w" class="input is-small" style="width:80px;" min="1" value="1920"' in html + assert 'id="scene-camera-h" class="input is-small" style="width:80px;" min="1" value="1080"' in html def test_screen_set_scene_size_route_rejects_invalid_dimensions(client, tmp_game_slug_cleanup):