Dev #11
@@ -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 }),
|
||||
|
||||
@@ -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. -->
|
||||
<p class="hint" style="background:var(--panel); border:1px solid var(--border); border-radius:8px; padding:10px 14px; margin:10px 0; display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;">
|
||||
<span>🎮 Jeu 2D — scène à taille fixe ({{ screen.scene_width }}×{{ screen.scene_height }} px).</span>
|
||||
{% if world_width > screen.scene_width or world_height > screen.scene_height %}
|
||||
<!-- "📐 Agrandir la caméra à la zone visible" : fait de tout le
|
||||
"monde" affiché (voir world_width/world_height, routes/scenes/
|
||||
scene_edit_view.py) la scène/caméra elle-même — n'apparaît que si
|
||||
un fond dépasse encore la scène nominale (voir "🎥 Champ de la
|
||||
caméra" plus bas), inutile sinon. -->
|
||||
<button type="button" class="button is-small" onclick="expandCameraToWorld({{ world_width }}, {{ world_height }})">📐 Agrandir la caméra à la zone visible ({{ world_width }}×{{ world_height }} px)</button>
|
||||
{% endif %}
|
||||
<span>🎮 Jeu 2D — scène à taille fixe.</span>
|
||||
<!-- Taille de la CAMÉRA (scene_width/scene_height) — TOUJOURS
|
||||
modifiable ici, directement en pixels (demande explicite : "la
|
||||
caméra a la même taille [que le rectangle de prévisualisation],
|
||||
c'est tout"), pas seulement suggérée automatiquement quand un
|
||||
fond dépasse (voir toujours "🎥 Champ de la caméra" plus bas si
|
||||
c'est le cas, purement informatif dans ce cas). -->
|
||||
<span style="display:flex; align-items:center; gap:6px;">
|
||||
<label class="hint" style="margin:0;">Caméra (px)
|
||||
<input type="number" id="scene-camera-w" class="input is-small" style="width:80px;" min="1" value="{{ screen.scene_width }}">
|
||||
×
|
||||
<input type="number" id="scene-camera-h" class="input is-small" style="width:80px;" min="1" value="{{ screen.scene_height }}">
|
||||
</label>
|
||||
<button type="button" class="button is-small" onclick="applyCameraSize()">Appliquer</button>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div class="builder3" id="builder3">
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user