Add StageBackgroundView and related tests for plain background functionality

- Implemented StageBackgroundView class for managing sky and plain backgrounds in the stage.
- Added functionality to set background type and color, bind camera, and apply themes.
- Created test_phase19_plain_background.gd to validate plain background behavior and migration.
- Developed test_phase19_starter_chooser_layout.gd to ensure proper layout and functionality of the starter chooser.
- Included visual capture tests for UI elements and interactions.
This commit is contained in:
2026-10-22 16:18:25 -04:00
parent db677dc194
commit 59f1817063
43 changed files with 2403 additions and 160 deletions
+4 -2
View File
@@ -1,7 +1,9 @@
{ {
"version": "1.5", "version": "1.7",
"scene_name": "Blank Scene", "scene_name": "Open Sky",
"sky_id": "sky_neutral", "sky_id": "sky_neutral",
"background_kind": "sky",
"plain_color": "#F5EFE0",
"camera": {"position": {"x": 0.0, "y": -400.0}, "zoom": 0.5}, "camera": {"position": {"x": 0.0, "y": -400.0}, "zoom": 0.5},
"objects": [], "objects": [],
"event_rules": [], "event_rules": [],
@@ -0,0 +1,11 @@
{
"version": "1.7",
"scene_name": "Plain Background",
"sky_id": "sky_neutral",
"background_kind": "plain",
"plain_color": "#F5EFE0",
"camera": {"position": {"x": 0.0, "y": -400.0}, "zoom": 0.5},
"objects": [],
"event_rules": [],
"metadata": {"created_unix": 1792022400, "modified_unix": 1792022400, "autosave": false, "source_path": ""}
}
@@ -87,6 +87,7 @@ This document tracks known technical debt, optimization opportunities, and minor
| 75 | **Old Brick/Wood wall colors were saved but not rendered** — v1.5 walls can carry the old default green while their brick and wood palettes were hard-coded. | Low | Planned migration | Scene v1.6 migration replaces only the old green placeholder on pre-v1.6 Brick/Wood entries with natural finish defaults; Paint and non-placeholder colors remain. The exact placeholder could have been intentionally authored in an older file, which cannot be distinguished retrospectively. New v1.6 colors are authoritative, including green Brick/Wood. See `docs/specs/phase_19_background_ground_and_wall_color.md`. (2026-10-17) | | 75 | **Old Brick/Wood wall colors were saved but not rendered** — v1.5 walls can carry the old default green while their brick and wood palettes were hard-coded. | Low | Planned migration | Scene v1.6 migration replaces only the old green placeholder on pre-v1.6 Brick/Wood entries with natural finish defaults; Paint and non-placeholder colors remain. The exact placeholder could have been intentionally authored in an older file, which cannot be distinguished retrospectively. New v1.6 colors are authoritative, including green Brick/Wood. See `docs/specs/phase_19_background_ground_and_wall_color.md`. (2026-10-17) |
| 76 | **Camera-aware Sky redraws vector motifs while framing changes** — the former static Sky drew motifs only when the preset or viewport changed. | Low | Planned | The Phase 19 Sky addition keeps one screen-space `StageSkyView`, redraws only when a bound camera's effective framing changes, and caches reusable cloud/moon curve samples where practical. Measure sustained pan/zoom cost in a rendered Stage before adding a raster or shader path. The fixed reference frame and bounded response can saturate at distant camera positions; that is an accepted composition trade-off, not scene state to persist. See `docs/specs/phase_19_scenery_backgrounds_surface_finishes.md#phase-19-addition-camera-aware-sky-details`. (2026-10-21) | | 76 | **Camera-aware Sky redraws vector motifs while framing changes** — the former static Sky drew motifs only when the preset or viewport changed. | Low | Planned | The Phase 19 Sky addition keeps one screen-space `StageSkyView`, redraws only when a bound camera's effective framing changes, and caches reusable cloud/moon curve samples where practical. Measure sustained pan/zoom cost in a rendered Stage before adding a raster or shader path. The fixed reference frame and bounded response can saturate at distant camera positions; that is an accepted composition trade-off, not scene state to persist. See `docs/specs/phase_19_scenery_backgrounds_surface_finishes.md#phase-19-addition-camera-aware-sky-details`. (2026-10-21) |
| 77 | **Starter surfaces guarantee a finite pan envelope, not arbitrary camera framing** — the two bundled sets use a fixed authored width to keep their scene data simple. | Low | Implemented; visual review pending | The authored envelope is a 1,280-logical-pixel viewport at zoom 0.5, ±1,000 world units of travel, and 100 units of margin per side. User review prompted an opaque Town Grass Background ground and separate scale-1 tile rows. Twenty-five 192-unit tiles cover the 4,760-unit minimum; Asphalt has 27 tiles (5,184 units) so the road extends one tile beyond the sidewalk at both ends. Navigation merges contiguous tile tops and routes the 32-unit curb step at the exposed ends without merging Ground objects or colliders. The focused suite passes 515 assertions, including the curb step and PLAY landing. The camera remains unrestricted, so wider viewports, farther pans, and zoomed-out shots can reveal finite ends. Rendered seam review remains pending. See docs/specs/phase_19_starter_scene_composition.md. (2026-10-21) | 77 | **Starter surfaces guarantee a finite pan envelope, not arbitrary camera framing** — the two bundled sets use a fixed authored width to keep their scene data simple. | Low | Implemented; visual review pending | The authored envelope is a 1,280-logical-pixel viewport at zoom 0.5, ±1,000 world units of travel, and 100 units of margin per side. User review prompted an opaque Town Grass Background ground and separate scale-1 tile rows. Twenty-five 192-unit tiles cover the 4,760-unit minimum; Asphalt has 27 tiles (5,184 units) so the road extends one tile beyond the sidewalk at both ends. Navigation merges contiguous tile tops and routes the 32-unit curb step at the exposed ends without merging Ground objects or colliders. The focused suite passes 515 assertions, including the curb step and PLAY landing. The camera remains unrestricted, so wider viewports, farther pans, and zoomed-out shots can reveal finite ends. Rendered seam review remains pending. See docs/specs/phase_19_starter_scene_composition.md. (2026-10-21)
| 78 | **Plain Background adds a second backdrop kind while Sky remains a separate renderer** — live Stage, starter previews, and chooser cards must agree on kind and remembered color. | Medium | Spec prepared; implementation pending | Phase 19 composes one shared `StageBackgroundView` from the existing Sky view and an opaque fill. Scene v1.7 stores active kind, last Sky ID, and confirmed plain color; all older scenes migrate as Sky. `SandboxStage` owns the transient custom-picker draft, which must never enter Save or autosave. The existing chooser's four-Sky layout and 42 px compact swatches need targeted extension, and grid/gizmo contrast needs theme-backed treatment for light and dark fills. Rendered pan/zoom/resize, legacy migration, and every draft-cancel exit remain verification gates. See `docs/specs/phase_19_plain_background.md`. (2026-10-22) |
--- ---
@@ -188,4 +189,6 @@ This document tracks known technical debt, optimization opportunities, and minor
| 2026-10-21 | Implemented the approved starter-scene composition spec. Town Street and Living Room now use continuous 4,760-unit support surfaces, aligned bases, and camera-derived starter-card framing; both edited scene files use current v1.6. The focused production-load/save-reopen/PLAY composition test passed 177 assertions, with measured visible-contact geometry within 0.225 logical pixels. The broader scenery suite exits 1 on nine other background-card and wall-erasure/capture-bar assertions, while the new surface assertions pass. GUI capture exited 134 and headless capture produced no image, so rendered-pixel checks, pan-endpoint seam inspection, narrow viewport/zoom-in framing, and user/editor verification remain pending. Updated #77 from planned to implemented with the finite-camera limitation accepted. See `docs/specs/phase_19_starter_scene_composition.md`. | 2026-10-21 | Implemented the approved starter-scene composition spec. Town Street and Living Room now use continuous 4,760-unit support surfaces, aligned bases, and camera-derived starter-card framing; both edited scene files use current v1.6. The focused production-load/save-reopen/PLAY composition test passed 177 assertions, with measured visible-contact geometry within 0.225 logical pixels. The broader scenery suite exits 1 on nine other background-card and wall-erasure/capture-bar assertions, while the new surface assertions pass. GUI capture exited 134 and headless capture produced no image, so rendered-pixel checks, pan-endpoint seam inspection, narrow viewport/zoom-in framing, and user/editor verification remain pending. Updated #77 from planned to implemented with the finite-camera limitation accepted. See `docs/specs/phase_19_starter_scene_composition.md`.
| 2026-10-21 | Revised the starters after the user's Town Street screenshot exposed Sky clouds below the skyline and the user rejected oversized scaled Ground blocks. Added an opaque Grass Background ground, replaced the sidewalk and both starter floors with scale-1 tile rows, and extended Asphalt by one tile at each end so the road is accessible. The focused production-path test passed 515 assertions, including navigation across tile seams, sidewalk-to-road routing, and a PLAY actor landing grounded on Asphalt. The broader scenery suite still exits 1 on the same nine Sky-preview/gallery and Scenery-edit UI assertions observed before this revision; its new surface assertions pass. A bounded GUI capture exited 134 without an image, so rendered pixels, pan endpoints, card previews, narrow viewport/zoom-in states, and user/editor review remain pending. See `docs/specs/phase_19_starter_scene_composition.md`. | 2026-10-21 | Revised the starters after the user's Town Street screenshot exposed Sky clouds below the skyline and the user rejected oversized scaled Ground blocks. Added an opaque Grass Background ground, replaced the sidewalk and both starter floors with scale-1 tile rows, and extended Asphalt by one tile at each end so the road is accessible. The focused production-path test passed 515 assertions, including navigation across tile seams, sidewalk-to-road routing, and a PLAY actor landing grounded on Asphalt. The broader scenery suite still exits 1 on the same nine Sky-preview/gallery and Scenery-edit UI assertions observed before this revision; its new surface assertions pass. A bounded GUI capture exited 134 without an image, so rendered pixels, pan endpoints, card previews, narrow viewport/zoom-in states, and user/editor review remain pending. See `docs/specs/phase_19_starter_scene_composition.md`.
| 2026-10-22 | Prepared and revised the Phase 19 Plain Background architecture specification (`docs/specs/phase_19_plain_background.md`) for final user sign-off. The accepted composed Stage backdrop view serves live Stage and previews; scene v1.7 persists active kind, last Sky ID, and confirmed plain color while migrating all older scenes as Sky. Color drafts stay out of Save/autosave, and theme-backed grid and two-tone gizmo overlays address light fills without changing art. Per user feedback, the current-color chip is the sole custom-picker entry, the separate More colors button is removed, and the custom picker uses a simple Preview label without a temporary-state helper message. Logged #78 for the chooser extension and rendered verification gates. No runtime code or tests changed. |
_End of Log_ _End of Log_
+2
View File
@@ -50,6 +50,8 @@ Priorities are recommendations for discussion, not a committed release schedule.
16. **Gentle camera-aware Sky details** — **Status:** Planned · **Suggested priority:** Medium. **Plan:** [Phase 19 — Scenery, Backgrounds, and Surface Finishes, camera-aware Sky addendum](../plans/phase_19_scenery_backgrounds_surface_finishes.md#camera-aware-sky-details-addendum). **Intent:** Let clouds, sun, moon, and stars respond gently and automatically to Stage camera pan and zoom while the Sky gradient always fills the screen. Children choose a Sky and direct the scene without adjusting a motion control. **Rationale:** A small amount of camera response connects the Sky details to a dramatic shot while keeping them visually distant and avoiding a new child-facing setting. Each preset can tune its own response so details stay composed, clear of the main action, and inside the viewport. Background ground remains world-anchored and supplies the horizon. Keep the response bounded across EDIT, DIRECT, PLAY, viewport resize, and saved camera framing; do not add a slider or make Sky details establish a ground line. **Connections:** Scenery backlog item 5, Backdrop horizon and edge treatment (backlog item 13), `scripts/stage/scenery/stage_sky_view.gd`, `scripts/stage/scenery/stage_background_ground.gd`, `scripts/editors/stage/sandbox_stage.gd`. 16. **Gentle camera-aware Sky details** — **Status:** Planned · **Suggested priority:** Medium. **Plan:** [Phase 19 — Scenery, Backgrounds, and Surface Finishes, camera-aware Sky addendum](../plans/phase_19_scenery_backgrounds_surface_finishes.md#camera-aware-sky-details-addendum). **Intent:** Let clouds, sun, moon, and stars respond gently and automatically to Stage camera pan and zoom while the Sky gradient always fills the screen. Children choose a Sky and direct the scene without adjusting a motion control. **Rationale:** A small amount of camera response connects the Sky details to a dramatic shot while keeping them visually distant and avoiding a new child-facing setting. Each preset can tune its own response so details stay composed, clear of the main action, and inside the viewport. Background ground remains world-anchored and supplies the horizon. Keep the response bounded across EDIT, DIRECT, PLAY, viewport resize, and saved camera framing; do not add a slider or make Sky details establish a ground line. **Connections:** Scenery backlog item 5, Backdrop horizon and edge treatment (backlog item 13), `scripts/stage/scenery/stage_sky_view.gd`, `scripts/stage/scenery/stage_background_ground.gd`, `scripts/editors/stage/sandbox_stage.gd`.
17. **Plain Background starter and editable solid background** — **Status:** Planned · **Suggested priority:** High. **Plan:** [Phase 19 — Plain Background](../plans/phase_19_plain_background.md). **Intent:** Add **Plain Background** as a fourth card in New Scene, alongside **Open Sky**, Town Street, and Living Room. It opens an empty Stage with no Sky imagery, Ground, or objects, then lets children choose a solid full-screen background color in EDIT. Rename the current empty starter with its neutral Sky to **Open Sky** so the two choices are distinct. **Rationale:** The current Blank Scene has no objects but displays a gray gradient, sun, and clouds, so it does not feel completely empty. A plain color makes the empty canvas intentional while keeping Sky presets available for other scenes. Give the Plain Background card a distinct flat-color preview. Place the color choice beside Sky in the existing Scenery → Backgrounds flow. Treat the background as scene-wide rather than a selectable rectangle, reuse the look of the existing Stage color chooser and its recent/preset swatches, and preserve the selected plain color across save/reopen and when temporarily switching to a Sky. Existing scenes with `sky_neutral` should retain their current appearance. **Connections:** Scenery backlog item 5, `content/stages/starters/blank.scene`, `scripts/editors/stage/stage_asset_browser.gd`, `scripts/shared/ui/asset_selector.gd`, `scripts/shared/stage_ui/stage_surface_color_controls.gd`, `scripts/shared/stage_ui/stage_surface_color_dialog.gd`, `scripts/stage/stage_scene_io.gd`, `scripts/editors/stage/stage_scene_adapter.gd`, `scripts/stage/scenery/stage_sky_view.gd`, `scripts/editors/stage/sandbox_stage.gd`.
## Entry format ## Entry format
For each feature, record: For each feature, record:
Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

@@ -0,0 +1,78 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="1000" viewBox="0 0 1600 1000">
<defs>
<pattern id="grid" width="64" height="64" patternUnits="userSpaceOnUse">
<path d="M64 0H0V64" fill="none" stroke="#FFFFFF" stroke-opacity=".055" stroke-width="1"/>
</pattern>
<linearGradient id="sky" x2="0" y2="1"><stop stop-color="#626E7E"/><stop offset="1" stop-color="#D3DEE5"/></linearGradient>
<linearGradient id="day" x2="0" y2="1"><stop stop-color="#52ADE8"/><stop offset="1" stop-color="#DFF5FF"/></linearGradient>
<linearGradient id="room" x2="0" y2="1"><stop stop-color="#DAD0B7"/><stop offset="1" stop-color="#F4E8CF"/></linearGradient>
</defs>
<rect width="1600" height="1000" fill="#2A313B"/>
<rect width="1600" height="1000" fill="url(#grid)"/>
<rect x="84" y="54" width="1432" height="892" rx="30" fill="#202735" stroke="#566173" stroke-width="2"/>
<text x="136" y="123" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="42" font-weight="700">Choose a starter scene</text>
<text x="137" y="160" fill="#AEB8C8" font-family="Arial, sans-serif" font-size="21">Pick a place to begin. You can change the background later.</text>
<!-- Plain Background card -->
<g>
<rect x="134" y="190" width="638" height="302" rx="16" fill="#171C25" stroke="#22C6FF" stroke-width="4"/>
<rect x="146" y="202" width="614" height="170" rx="10" fill="#F5EFE0"/>
<rect x="146" y="202" width="614" height="170" rx="10" fill="none" stroke="#FFFFFF" stroke-opacity=".35" stroke-width="2"/>
<text x="453" y="416" text-anchor="middle" fill="#F8FAFC" font-family="Arial, sans-serif" font-size="28" font-weight="700">Plain Background</text>
<text x="453" y="449" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="20">An empty stage with one color.</text>
<text x="453" y="476" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="20">Choose a new color whenever you like.</text>
</g>
<!-- Open Sky card -->
<g>
<rect x="798" y="190" width="638" height="302" rx="16" fill="#171C25" stroke="#465061" stroke-width="2"/>
<rect x="810" y="202" width="614" height="170" rx="10" fill="url(#sky)"/>
<circle cx="1286" cy="250" r="22" fill="#FFF0A2" stroke="#FFE27A" stroke-width="6"/>
<g fill="#F7FBFF" stroke="#DCE7F0" stroke-width="3">
<ellipse cx="921" cy="275" rx="37" ry="15"/><circle cx="902" cy="268" r="15"/><circle cx="925" cy="261" r="19"/><circle cx="946" cy="271" r="14"/>
<ellipse cx="1115" cy="316" rx="39" ry="14"/><circle cx="1094" cy="309" r="14"/><circle cx="1117" cy="302" r="18"/><circle cx="1140" cy="313" r="13"/>
</g>
<text x="1117" y="416" text-anchor="middle" fill="#F8FAFC" font-family="Arial, sans-serif" font-size="28" font-weight="700">Open Sky</text>
<text x="1117" y="449" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="20">An empty stage with a soft sky.</text>
<text x="1117" y="476" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="20">Sun and clouds, ready for your story.</text>
</g>
<!-- Town Street card -->
<g>
<rect x="134" y="522" width="638" height="302" rx="16" fill="#171C25" stroke="#465061" stroke-width="2"/>
<rect x="146" y="534" width="614" height="170" rx="10" fill="url(#day)"/>
<circle cx="695" cy="566" r="17" fill="#FFE99A"/>
<g fill="#FFFFFF" stroke="#DCE7F0" stroke-width="2">
<ellipse cx="228" cy="574" rx="29" ry="11"/><circle cx="215" cy="568" r="11"/><circle cx="231" cy="563" r="14"/><circle cx="247" cy="572" r="10"/>
<ellipse cx="430" cy="600" rx="32" ry="11"/><circle cx="414" cy="594" r="11"/><circle cx="432" cy="588" r="14"/><circle cx="450" cy="598" r="10"/>
</g>
<rect x="146" y="643" width="614" height="39" fill="#58996B"/>
<rect x="146" y="682" width="614" height="22" fill="#5C626A"/>
<path d="M322 642L393 586L466 642Z" fill="#D86F58" stroke="#282D35" stroke-width="4"/>
<rect x="338" y="642" width="108" height="40" fill="#EAD6AE" stroke="#282D35" stroke-width="4"/>
<rect x="373" y="650" width="28" height="32" fill="#55A6D0" stroke="#282D35" stroke-width="3"/>
<rect x="394" y="612" width="24" height="27" fill="#68B9E2" stroke="#282D35" stroke-width="3"/>
<text x="453" y="752" text-anchor="middle" fill="#F8FAFC" font-family="Arial, sans-serif" font-size="28" font-weight="700">Town Street</text>
<text x="453" y="785" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="20">Cloudy sky, shops, trees,</text>
<text x="453" y="812" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="20">sidewalk, and road.</text>
</g>
<!-- Living Room card -->
<g>
<rect x="798" y="522" width="638" height="302" rx="16" fill="#171C25" stroke="#465061" stroke-width="2"/>
<rect x="810" y="534" width="614" height="170" rx="10" fill="url(#room)"/>
<rect x="810" y="534" width="614" height="67" fill="url(#day)"/>
<circle cx="1306" cy="567" r="17" fill="#FFE99A"/>
<rect x="1038" y="570" width="103" height="98" fill="#91C5E3" stroke="#704E3D" stroke-width="8"/>
<path d="M1089 574V664M1042 620H1137" stroke="#FFF8E9" stroke-width="7"/>
<rect x="810" y="676" width="614" height="28" fill="#926545"/>
<rect x="876" y="630" width="135" height="54" rx="14" fill="#6D8E67" stroke="#4E5E49" stroke-width="4"/>
<rect x="890" y="614" width="107" height="36" rx="12" fill="#7FA17A" stroke="#4E5E49" stroke-width="4"/>
<text x="1117" y="752" text-anchor="middle" fill="#F8FAFC" font-family="Arial, sans-serif" font-size="28" font-weight="700">Living Room</text>
<text x="1117" y="785" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="20">A cozy room with a window,</text>
<text x="1117" y="812" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="20">rug, and furniture.</text>
</g>
<rect x="692" y="864" width="216" height="58" rx="18" fill="#171C25" stroke="#586273" stroke-width="2"/>
<text x="800" y="902" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="24" font-weight="700">Close</text>
</svg>

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

@@ -0,0 +1,74 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="1000" viewBox="0 0 1600 1000">
<defs>
<pattern id="grid" width="64" height="64" patternUnits="userSpaceOnUse"><path d="M64 0H0V64" fill="none" stroke="#FFFFFF" stroke-opacity=".055" stroke-width="1"/></pattern>
<linearGradient id="clear" x2="0" y2="1"><stop stop-color="#52ADE8"/><stop offset="1" stop-color="#DFF5FF"/></linearGradient>
<linearGradient id="cloudy" x2="0" y2="1"><stop stop-color="#72839A"/><stop offset="1" stop-color="#D4E0E4"/></linearGradient>
<linearGradient id="sunset" x2="0" y2="1"><stop stop-color="#765A91"/><stop offset=".55" stop-color="#DF8E9A"/><stop offset="1" stop-color="#FFC980"/></linearGradient>
<linearGradient id="night" x2="0" y2="1"><stop stop-color="#101A3B"/><stop offset="1" stop-color="#536F97"/></linearGradient>
</defs>
<rect width="1600" height="1000" fill="#2A313B"/><rect width="1600" height="1000" fill="url(#grid)"/>
<rect x="72" y="38" width="1456" height="924" rx="30" fill="#202735" stroke="#566173" stroke-width="2"/>
<text x="120" y="102" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="38" font-weight="700">Scenery</text>
<rect x="120" y="124" width="230" height="54" rx="16" fill="#12394A" stroke="#22C6FF" stroke-width="3"/>
<text x="235" y="160" text-anchor="middle" fill="#F6FAFF" font-family="Arial, sans-serif" font-size="22" font-weight="700">Backgrounds</text>
<rect x="365" y="124" width="190" height="54" rx="16" fill="#171C25" stroke="#566173" stroke-width="2"/>
<text x="460" y="160" text-anchor="middle" fill="#DCE3EC" font-family="Arial, sans-serif" font-size="22">Artwork</text>
<text x="120" y="224" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="25" font-weight="700">Choose the scene background</text>
<!-- Plain Background -->
<g>
<rect x="120" y="250" width="420" height="246" rx="16" fill="#171C25" stroke="#22C6FF" stroke-width="4"/>
<rect x="132" y="262" width="396" height="157" rx="10" fill="#F5EFE0"/>
<rect x="145" y="274" width="165" height="32" rx="12" fill="#12394A" stroke="#22C6FF" stroke-width="2"/>
<text x="227" y="297" text-anchor="middle" fill="#F7FBFF" font-family="Arial, sans-serif" font-size="16" font-weight="700">Current background</text>
<text x="330" y="458" text-anchor="middle" fill="#F6F8FC" font-family="Arial, sans-serif" font-size="23" font-weight="700">Plain Background</text>
</g>
<!-- Clear Day -->
<g>
<rect x="590" y="250" width="420" height="246" rx="16" fill="#171C25" stroke="#465061" stroke-width="2"/>
<rect x="602" y="262" width="396" height="157" rx="10" fill="url(#clear)"/>
<circle cx="910" cy="304" r="23" fill="#FFE99A" stroke="#FFF3BD" stroke-width="5"/>
<g fill="#FFFFFF" stroke="#DFEAF1" stroke-width="2"><ellipse cx="714" cy="354" rx="43" ry="14"/><circle cx="694" cy="348" r="13"/><circle cx="717" cy="341" r="18"/><circle cx="741" cy="352" r="12"/></g>
<text x="800" y="458" text-anchor="middle" fill="#F6F8FC" font-family="Arial, sans-serif" font-size="23" font-weight="700">Clear Day</text>
</g>
<!-- Cloudy Day -->
<g>
<rect x="1060" y="250" width="420" height="246" rx="16" fill="#171C25" stroke="#465061" stroke-width="2"/>
<rect x="1072" y="262" width="396" height="157" rx="10" fill="url(#cloudy)"/>
<g fill="#F8FBFE" stroke="#E2EBF1" stroke-width="2"><ellipse cx="1190" cy="326" rx="42" ry="14"/><circle cx="1170" cy="320" r="14"/><circle cx="1194" cy="312" r="18"/><circle cx="1216" cy="324" r="12"/><ellipse cx="1360" cy="372" rx="42" ry="13"/><circle cx="1342" cy="366" r="12"/><circle cx="1362" cy="358" r="17"/><circle cx="1384" cy="369" r="12"/></g>
<text x="1270" y="458" text-anchor="middle" fill="#F6F8FC" font-family="Arial, sans-serif" font-size="23" font-weight="700">Cloudy Day</text>
</g>
<!-- Sunset -->
<g>
<rect x="120" y="520" width="420" height="220" rx="16" fill="#171C25" stroke="#465061" stroke-width="2"/>
<rect x="132" y="532" width="396" height="135" rx="10" fill="url(#sunset)"/>
<circle cx="330" cy="623" r="23" fill="#FFE09B"/><path d="M132 640Q330 600 528 640V667H132Z" fill="#5C6D76" opacity=".7"/>
<text x="330" y="713" text-anchor="middle" fill="#F6F8FC" font-family="Arial, sans-serif" font-size="23" font-weight="700">Sunset</text>
</g>
<!-- Starry Night -->
<g>
<rect x="590" y="520" width="420" height="220" rx="16" fill="#171C25" stroke="#465061" stroke-width="2"/>
<rect x="602" y="532" width="396" height="135" rx="10" fill="url(#night)"/>
<g fill="#FFE8A5"><circle cx="664" cy="563" r="3"/><circle cx="740" cy="604" r="3"/><circle cx="806" cy="555" r="4"/><circle cx="927" cy="580" r="3"/><circle cx="889" cy="635" r="3"/></g>
<path d="M875 560a28 28 0 1 0 26 46a22 22 0 1 1-26-46" fill="#FFF0BE"/>
<text x="800" y="713" text-anchor="middle" fill="#F6F8FC" font-family="Arial, sans-serif" font-size="23" font-weight="700">Starry Night</text>
</g>
<text x="1060" y="558" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="22" font-weight="700">More backgrounds</text>
<rect x="1060" y="578" width="195" height="100" rx="15" fill="#171C25" stroke="#566173" stroke-width="2"/>
<rect x="1077" y="596" width="52" height="56" rx="8" fill="#C6A36C" stroke="#E7D0A6" stroke-width="2"/>
<path d="M1083 606h40M1083 618h40M1083 630h40M1083 642h40" stroke="#896644" stroke-width="3"/>
<text x="1183" y="635" text-anchor="middle" fill="#F6F8FC" font-family="Arial, sans-serif" font-size="19" font-weight="700">Wall panel</text>
<rect x="1274" y="578" width="206" height="100" rx="15" fill="#171C25" stroke="#566173" stroke-width="2"/>
<rect x="1290" y="596" width="52" height="56" rx="8" fill="#7AA474" stroke="#A5C39C" stroke-width="2"/>
<path d="M1297 609h38M1297 622h38M1297 635h38" stroke="#D7E6C5" stroke-width="2" opacity=".7"/>
<text x="1402" y="622" text-anchor="middle" fill="#F6F8FC" font-family="Arial, sans-serif" font-size="16" font-weight="700">Background</text>
<text x="1402" y="644" text-anchor="middle" fill="#F6F8FC" font-family="Arial, sans-serif" font-size="16" font-weight="700">ground</text>
<rect x="692" y="874" width="216" height="58" rx="18" fill="#171C25" stroke="#586273" stroke-width="2"/>
<text x="800" y="912" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="24" font-weight="700">Close</text>
</svg>

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

@@ -0,0 +1,45 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="1000" viewBox="0 0 1600 1000">
<defs>
<pattern id="grid" width="64" height="64" patternUnits="userSpaceOnUse"><path d="M64 0H0V64" fill="none" stroke="#FFFFFF" stroke-opacity=".055" stroke-width="1"/></pattern>
</defs>
<rect width="1600" height="1000" fill="#2A313B"/><rect width="1600" height="1000" fill="url(#grid)"/>
<rect x="76" y="46" width="1448" height="908" rx="30" fill="#202735" stroke="#566173" stroke-width="2"/>
<rect x="116" y="82" width="250" height="54" rx="16" fill="#171C25" stroke="#566173" stroke-width="2"/>
<text x="241" y="117" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="21" font-weight="700">‹ Backgrounds</text>
<text x="116" y="194" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="38" font-weight="700">Plain Background</text>
<text x="118" y="231" fill="#B8C2D0" font-family="Arial, sans-serif" font-size="21">Tap a color to use it on the Stage.</text>
<text x="120" y="279" fill="#EAF0F8" font-family="Arial, sans-serif" font-size="22" font-weight="700">Preview</text>
<rect x="120" y="296" width="1360" height="190" rx="22" fill="#F5EFE0" stroke="#F4F7FB" stroke-width="4"/>
<rect x="120" y="520" width="310" height="280" rx="18" fill="#171C25" stroke="#3C4656" stroke-width="2"/>
<text x="150" y="564" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="22" font-weight="700">Color</text>
<rect x="150" y="584" width="68" height="68" rx="12" fill="#F5EFE0" stroke="#22C6FF" stroke-width="4"/>
<circle cx="212" cy="646" r="16" fill="#087DBA" stroke="#44CCFF" stroke-width="2"/>
<path d="M205 652 L207 646 L215 638 L220 643 L212 651 Z M213 640 L218 645 M205 652 L211 650" fill="none" stroke="#FFFFFF" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>
<text x="234" y="625" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="23" font-weight="700">#F5EFE0</text>
<text x="150" y="696" fill="#AEB8C8" font-family="Arial, sans-serif" font-size="18">Tap swatch to pick a custom color</text>
<rect x="454" y="520" width="470" height="280" rx="18" fill="#171C25" stroke="#3C4656" stroke-width="2"/>
<text x="484" y="564" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="22" font-weight="700">Recently used</text>
<g stroke="#DCE3EC" stroke-width="3">
<rect x="484" y="590" width="64" height="64" rx="12" fill="#FFB703"/><rect x="560" y="590" width="64" height="64" rx="12" fill="#24B9E8"/>
<rect x="636" y="590" width="64" height="64" rx="12" fill="#00A542"/><rect x="712" y="590" width="64" height="64" rx="12" fill="#0798EA"/>
<rect x="788" y="590" width="64" height="64" rx="12" fill="#F5EFE0" stroke="#22C6FF" stroke-width="5"/>
</g>
<g stroke="#DCE3EC" stroke-width="3">
<rect x="484" y="682" width="64" height="64" rx="12" fill="#F04C53"/>
<rect x="560" y="682" width="64" height="64" rx="12" fill="#A855F7"/>
<rect x="636" y="682" width="64" height="64" rx="12" fill="#FFFFFF"/>
</g>
<rect x="948" y="520" width="532" height="280" rx="18" fill="#171C25" stroke="#3C4656" stroke-width="2"/>
<text x="978" y="564" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="22" font-weight="700">Colors</text>
<g stroke="#DCE3EC" stroke-width="3">
<rect x="978" y="590" width="64" height="64" rx="12" fill="#FFFFFF"/><rect x="1054" y="590" width="64" height="64" rx="12" fill="#171717"/>
<rect x="1130" y="590" width="64" height="64" rx="12" fill="#22B8E6"/><rect x="1206" y="590" width="64" height="64" rx="12" fill="#FFB703"/>
<rect x="1282" y="590" width="64" height="64" rx="12" fill="#2AD67B"/><rect x="1358" y="590" width="64" height="64" rx="12" fill="#F04C53"/>
</g>
<rect x="670" y="858" width="260" height="62" rx="18" fill="#171C25" stroke="#586273" stroke-width="2"/>
<text x="800" y="898" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="22" font-weight="700">Back to Backgrounds</text>
</svg>

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

@@ -0,0 +1,49 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="1000" viewBox="0 0 1600 1000">
<defs>
<pattern id="grid" width="64" height="64" patternUnits="userSpaceOnUse"><path d="M64 0H0V64" fill="none" stroke="#FFFFFF" stroke-opacity=".055" stroke-width="1"/></pattern>
<linearGradient id="fieldBase" x1="0" x2="1"><stop stop-color="#F2BF48"/><stop offset="1" stop-color="#F2BF48"/></linearGradient>
<linearGradient id="whiteFade" x1="0" x2="1"><stop stop-color="#FFFFFF"/><stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/></linearGradient>
<linearGradient id="blackFade" x1="0" y1="0" x2="0" y2="1"><stop stop-color="#000000" stop-opacity="0"/><stop offset="1" stop-color="#000000"/></linearGradient>
<linearGradient id="hues" x1="0" y1="0" x2="0" y2="1"><stop stop-color="#FF0000"/><stop offset=".17" stop-color="#FFFF00"/><stop offset=".34" stop-color="#00FF00"/><stop offset=".51" stop-color="#00FFFF"/><stop offset=".68" stop-color="#0000FF"/><stop offset=".84" stop-color="#FF00FF"/><stop offset="1" stop-color="#FF0000"/></linearGradient>
</defs>
<rect width="1600" height="1000" fill="#2A313B"/><rect width="1600" height="1000" fill="url(#grid)"/>
<rect x="175" y="56" width="1250" height="888" rx="30" fill="#202735" stroke="#566173" stroke-width="2"/>
<text x="800" y="119" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="40" font-weight="700">Choose background color</text>
<text x="230" y="165" fill="#EAF0F8" font-family="Arial, sans-serif" font-size="22" font-weight="700">Preview</text>
<rect x="230" y="184" width="1140" height="145" rx="22" fill="#F5EFE0" stroke="#F4F7FB" stroke-width="4"/>
<!-- saturation and value field -->
<rect x="230" y="356" width="890" height="365" rx="10" fill="url(#fieldBase)"/>
<rect x="230" y="356" width="890" height="365" rx="10" fill="url(#whiteFade)"/>
<rect x="230" y="356" width="890" height="365" rx="10" fill="url(#blackFade)"/>
<rect x="230" y="356" width="890" height="365" rx="10" fill="none" stroke="#AEB8C8" stroke-width="2"/>
<circle cx="328" cy="412" r="12" fill="none" stroke="#111827" stroke-width="5"/><circle cx="328" cy="412" r="8" fill="none" stroke="#FFFFFF" stroke-width="3"/>
<!-- hue bar -->
<rect x="1144" y="356" width="76" height="365" rx="12" fill="url(#hues)" stroke="#AEB8C8" stroke-width="2"/>
<path d="M1136 397H1228" stroke="#10151E" stroke-width="8"/><path d="M1136 397H1228" stroke="#FFFFFF" stroke-width="4"/>
<!-- mode tabs -->
<rect x="230" y="744" width="990" height="56" rx="14" fill="#171C25" stroke="#566173" stroke-width="2"/>
<rect x="232" y="746" width="326" height="52" rx="12" fill="#2D3543" stroke="#22C6FF" stroke-width="2"/>
<text x="395" y="781" text-anchor="middle" fill="#FFFFFF" font-family="Arial, sans-serif" font-size="21" font-weight="700">RGB</text>
<path d="M560 750V795M890 750V795" stroke="#566173" stroke-width="2"/>
<text x="725" y="781" text-anchor="middle" fill="#DAE1EA" font-family="Arial, sans-serif" font-size="21">HSV</text>
<text x="1055" y="781" text-anchor="middle" fill="#DAE1EA" font-family="Arial, sans-serif" font-size="21">Linear</text>
<!-- selected value -->
<rect x="1245" y="356" width="125" height="365" rx="16" fill="#171C25" stroke="#3C4656" stroke-width="2"/>
<text x="1307" y="391" text-anchor="middle" fill="#AEB8C8" font-family="Arial, sans-serif" font-size="16">COLOR</text>
<rect x="1268" y="416" width="79" height="79" rx="14" fill="#F5EFE0" stroke="#22C6FF" stroke-width="3"/>
<text x="1307" y="531" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="16">Hex</text>
<rect x="1260" y="546" width="94" height="44" rx="9" fill="#252D3A" stroke="#657184" stroke-width="2"/>
<text x="1307" y="575" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="18">F5EFE0</text>
<text x="1307" y="634" text-anchor="middle" fill="#AEB8C8" font-family="Arial, sans-serif" font-size="15">R 245</text>
<text x="1307" y="662" text-anchor="middle" fill="#AEB8C8" font-family="Arial, sans-serif" font-size="15">G 239</text>
<text x="1307" y="690" text-anchor="middle" fill="#AEB8C8" font-family="Arial, sans-serif" font-size="15">B 224</text>
<rect x="835" y="850" width="230" height="62" rx="18" fill="#171C25" stroke="#586273" stroke-width="2"/>
<text x="950" y="890" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="22" font-weight="700">Back</text>
<rect x="1085" y="850" width="285" height="62" rx="18" fill="#087DBA" stroke="#44CCFF" stroke-width="3"/>
<text x="1227" y="890" text-anchor="middle" fill="#FFFFFF" font-family="Arial, sans-serif" font-size="22" font-weight="700">Use color</text>
</svg>

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

@@ -0,0 +1,92 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1800" height="1200" viewBox="0 0 1800 1200">
<defs>
<pattern id="grid" width="64" height="64" patternUnits="userSpaceOnUse">
<path d="M64 0H0V64" fill="none" stroke="#FFFFFF" stroke-opacity=".055" stroke-width="1"/>
</pattern>
<linearGradient id="open-sky" x2="0" y2="1"><stop stop-color="#626E7E"/><stop offset="1" stop-color="#D3DEE5"/></linearGradient>
<linearGradient id="town-sky" x2="0" y2="1"><stop stop-color="#52ADE8"/><stop offset="1" stop-color="#DFF5FF"/></linearGradient>
<linearGradient id="room-wall" x2="0" y2="1"><stop stop-color="#E6DABD"/><stop offset="1" stop-color="#F4E8CF"/></linearGradient>
<clipPath id="plain-clip"><rect x="134" y="198" width="742" height="276" rx="12"/></clipPath>
<clipPath id="sky-clip"><rect x="924" y="198" width="742" height="276" rx="12"/></clipPath>
<clipPath id="town-clip"><rect x="134" y="638" width="742" height="276" rx="12"/></clipPath>
<clipPath id="room-clip"><rect x="924" y="638" width="742" height="276" rx="12"/></clipPath>
</defs>
<rect width="1800" height="1200" fill="#2A313B"/>
<rect width="1800" height="1200" fill="url(#grid)"/>
<rect x="65" y="35" width="1670" height="1130" rx="30" fill="#202735" stroke="#566173" stroke-width="2"/>
<text x="122" y="111" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="46" font-weight="700">Choose a starter scene</text>
<text x="124" y="151" fill="#AEB8C8" font-family="Arial, sans-serif" font-size="23">Pick a place to begin. You can change the background later.</text>
<!-- The larger cards devote almost twice the original area to the scene preview. -->
<rect x="120" y="184" width="770" height="418" rx="20" fill="#171C25" stroke="#22C6FF" stroke-width="4"/>
<rect x="910" y="184" width="770" height="418" rx="20" fill="#171C25" stroke="#596474" stroke-width="2"/>
<rect x="120" y="624" width="770" height="418" rx="20" fill="#171C25" stroke="#596474" stroke-width="2"/>
<rect x="910" y="624" width="770" height="418" rx="20" fill="#171C25" stroke="#596474" stroke-width="2"/>
<g clip-path="url(#plain-clip)">
<rect x="134" y="198" width="742" height="276" fill="#F5EFE0"/>
</g>
<rect x="134" y="198" width="742" height="276" rx="12" fill="none" stroke="#FFFFFF" stroke-opacity=".38" stroke-width="2"/>
<g clip-path="url(#sky-clip)">
<rect x="924" y="198" width="742" height="276" fill="url(#open-sky)"/>
<circle cx="1525" cy="267" r="26" fill="#FFF1A8" stroke="#FFE27A" stroke-width="7"/>
<g fill="#F7FBFF" stroke="#DBE6EF" stroke-width="3">
<ellipse cx="1042" cy="297" rx="49" ry="19"/><circle cx="1014" cy="287" r="20"/><circle cx="1043" cy="278" r="25"/><circle cx="1077" cy="291" r="20"/>
<ellipse cx="1342" cy="365" rx="53" ry="18"/><circle cx="1312" cy="355" r="20"/><circle cx="1343" cy="345" r="25"/><circle cx="1378" cy="358" r="19"/>
</g>
</g>
<g clip-path="url(#town-clip)">
<rect x="134" y="638" width="742" height="276" fill="url(#town-sky)"/>
<circle cx="781" cy="699" r="24" fill="#FFE99A"/>
<g fill="#FFFFFF" stroke="#DCE7F0" stroke-width="3">
<ellipse cx="245" cy="707" rx="43" ry="16"/><circle cx="222" cy="699" r="17"/><circle cx="249" cy="690" r="21"/><circle cx="277" cy="704" r="15"/>
<ellipse cx="532" cy="737" rx="39" ry="14"/><circle cx="511" cy="730" r="15"/><circle cx="534" cy="721" r="19"/><circle cx="558" cy="733" r="14"/>
</g>
<rect x="134" y="823" width="742" height="47" fill="#5D9D70"/>
<rect x="134" y="870" width="742" height="44" fill="#575F68"/>
<path d="M329 820L432 728L534 820Z" fill="#D8705A" stroke="#28313A" stroke-width="5"/>
<rect x="349" y="820" width="166" height="51" fill="#E8D4AC" stroke="#28313A" stroke-width="5"/>
<rect x="415" y="834" width="39" height="37" fill="#58A7D4" stroke="#28313A" stroke-width="4"/>
<rect x="461" y="769" width="33" height="40" fill="#71BBDC" stroke="#28313A" stroke-width="4"/>
<path d="M647 821V746" stroke="#594D3B" stroke-width="12"/>
<circle cx="647" cy="738" r="48" fill="#4F9B67" stroke="#336D4C" stroke-width="5"/>
</g>
<g clip-path="url(#room-clip)">
<rect x="924" y="638" width="742" height="276" fill="url(#room-wall)"/>
<rect x="924" y="638" width="742" height="74" fill="url(#town-sky)"/>
<circle cx="1576" cy="680" r="23" fill="#FFE99A"/>
<rect x="1232" y="677" width="150" height="141" fill="#91C5E3" stroke="#704E3D" stroke-width="10"/>
<path d="M1307 683V812M1238 747H1376" stroke="#FFF8E9" stroke-width="8"/>
<rect x="924" y="866" width="742" height="48" fill="#926545"/>
<ellipse cx="1149" cy="865" rx="143" ry="26" fill="#BA7F5B"/>
<rect x="1041" y="792" width="226" height="81" rx="18" fill="#6D8E67" stroke="#4E5E49" stroke-width="6"/>
<rect x="1061" y="769" width="186" height="57" rx="18" fill="#80A17A" stroke="#4E5E49" stroke-width="6"/>
<rect x="1481" y="826" width="88" height="43" rx="6" fill="#C49371" stroke="#654C3E" stroke-width="5"/>
<path d="M1524 826V779" stroke="#755A43" stroke-width="6"/>
<circle cx="1524" cy="764" r="25" fill="#FFF5DF" stroke="#755A43" stroke-width="5"/>
</g>
<g fill="#F8FAFC" font-family="Arial, sans-serif" text-anchor="middle" font-weight="700" font-size="32">
<text x="505" y="521">Plain Background</text>
<text x="1295" y="521">Open Sky</text>
<text x="505" y="961">Town Street</text>
<text x="1295" y="961">Living Room</text>
</g>
<g fill="#F5F7FA" font-family="Arial, sans-serif" text-anchor="middle" font-size="22">
<text x="505" y="558">An empty stage with one color.</text>
<text x="505" y="589">Choose a new color whenever you like.</text>
<text x="1295" y="558">An empty stage with a soft sky.</text>
<text x="1295" y="589">Sun and clouds, ready for your story.</text>
<text x="505" y="998">Cloudy sky, shops, trees,</text>
<text x="505" y="1029">sidewalk, and road.</text>
<text x="1295" y="998">A cozy room with a window,</text>
<text x="1295" y="1029">rug, and furniture.</text>
</g>
<rect x="790" y="1077" width="220" height="64" rx="18" fill="#171C25" stroke="#667386" stroke-width="2"/>
<text x="900" y="1118" text-anchor="middle" fill="#F5F7FA" font-family="Arial, sans-serif" font-size="26" font-weight="700">Close</text>
</svg>

After

Width:  |  Height:  |  Size: 6.2 KiB

+130
View File
@@ -0,0 +1,130 @@
# Phase 19 — Plain Background
> **Status:** Accepted product direction for a focused Phase 19 addition. This is a design handoff to the spec-pipeline, not a UI/UX or architecture specification.
> **Relationship to Phase 19:** This brief updates only the earlier three-card **File → New** choice and the four-Sky-only **Backgrounds** choice. Other accepted Scenery, starter composition, Sky, Ground, and artwork behavior remains as described in the existing Phase 19 plans and specifications.
## Goal and audience
Give a child a genuinely empty Stage and an easy way to choose its background color. The audience is a child starting a scene through **File → New** or changing a scene's look in **EDIT**. A plain color can set a mood for an abstract story, title-like shot, or set built entirely from the child's own Ground, characters, Props, and Scenery.
The background is a scene-wide visual choice. It fills the camera view in **EDIT**, **DIRECT**, and **PLAY**, without adding a selectable Stage object or changing the colors or behavior of placed pieces.
## PNG mockups
**Review status:** The starter and Backgrounds PNGs are user-approved. The color-choices and custom-picker PNGs were revised per user feedback: tapping the current-color chip opens the picker without a separate **More colors** button, and the custom picker shows a simple **Preview** label with no temporary-state helper message. These revisions are included for final spec sign-off. The production initial color is warm off-white `#F5EFE0`; Plain Background previews use a uniform solid fill. Editable SVG source files sit beside each PNG.
- [New Scene starter chooser](assets/phase_19_plain_background/01_new_scene.png)
- [Larger New Scene chooser proposal](assets/phase_19_plain_background/05_large_starter_chooser.png) — expands the same four cards and gives each preview more room; retain the bounded, scrollable layout on smaller screens.
- [Scenery Backgrounds chooser](assets/phase_19_plain_background/02_background_picker.png)
- [Plain Background color choices](assets/phase_19_plain_background/03_color_choices.png)
- [Custom color picker](assets/phase_19_plain_background/04_custom_color_picker.png)
## Desired child outcome
- Start **Plain Background** and see one uninterrupted solid color, with no Sky imagery, Ground, characters, Props, or other placed objects.
- Recognize the existing empty starter as **Open Sky**: its current neutral gradient, sun, and clouds remain available.
- Find the background color in **EDIT → Scenery → Backgrounds**, beside the Sky choices, and use a familiar color preview, swatches, and picker.
- Change between a plain color and a Sky without losing the chosen plain color. Save, reopen, and see the same chosen background.
## Child flow and feedback
### File → New
The existing unsaved-work Save/Discard/Cancel gate runs before the starter chooser. Canceling the chooser leaves the open scene intact. The chooser presents four large illustrated cards; a chosen starter opens as a new, unsaved, editable scene.
```text
┌ Choose a starter scene ───────────────────────────────┐
│ ┌──────────────────────┐ ┌──────────────────────┐ │
│ │ [solid color preview]│ │ [soft sky preview] │ │
│ │ Plain Background │ │ Open Sky │ │
│ │ An empty stage with │ │ An empty stage with │ │
│ │ a color you can pick.│ │ a soft sky. │ │
│ └──────────────────────┘ └──────────────────────┘ │
│ ┌──────────────────────┐ ┌──────────────────────┐ │
│ │ [street preview] │ │ [room preview] │ │
│ │ Town Street │ │ Living Room │ │
│ └──────────────────────┘ └──────────────────────┘ │
│ [Close] │
└───────────────────────────────────────────────────────┘
```
The **Plain Background** card shows its actual initial solid fill. **Open Sky** is the existing sky-backed empty starter, renamed so its preview and label agree. Town Street and Living Room retain their current compositions and editability. On a narrow screen, cards wrap into one column within a bounded, scrollable chooser; the title and visible Close action remain reachable.
The initial Plain Background color is **warm off-white `#F5EFE0`**, approved as the starting look. It should read like paper and let typical character and artwork outlines remain visible. The Stage grid and selection outlines need contrast treatment so they remain legible over both light and dark child-selected colors.
### Change the background in EDIT
The child opens **Scenery → Backgrounds**. A **Plain Background** choice sits with the four existing Sky presets. The chooser shows which background is current with a clear border and words as well as color; keyboard focus remains visually separate from selection.
```text
┌ Choose Scenery ────────────────────────────────────────┐
│ [Backgrounds] [Artwork] │
│ Choose the scene background │
│ ┌───────────────────┐ ┌────────────┐ ┌────────────┐ │
│ │ [saved plain color]│ │ Clear Day │ │ Cloudy Day │ │
│ │ Plain Background │ └────────────┘ └────────────┘ │
│ │ Current background│ ┌────────────┐ ┌────────────┐ │
│ └───────────────────┘ │ Sunset │ │ Starry Night│ │
│ └────────────┘ └────────────┘ │
│ [Wall panel] [Background ground] │
│ [Close] │
└───────────────────────────────────────────────────────┘
```
Choosing the **Plain Background** card immediately switches the Stage to its remembered plain fill and opens its color choices. This background choice is confirmed at the card tap, just as a Sky card is. The child can close or go Back from the color choices while keeping that fill. Preset and recently used swatches are quick, **confirmed** color choices: tapping one immediately updates the entire Stage, the current-color preview, and recent colors. The current-color chip is a button; tapping it opens the fuller picker. There is no separate **More colors** button.
The full picker starts from the latest confirmed plain color. Moving its controls gives a tentative preview of the Stage background and the large color sample. **Use color** confirms that custom color, records it in recent colors, and returns to the plain color choices. **Back** or Cancel discards the custom draft, restores the confirmed plain fill from before the picker opened, and returns to the color choices. Back from the color choices returns to Backgrounds without undoing the card or swatch choices. This matches the established distinction between direct swatch selection and a custom-color draft.
```text
┌ Choose background color ──────────────────────────────┐
│ Preview: [wide uninterrupted solid color] │
│ Current color [■] #F5EFE0 (tap swatch to pick custom)│
│ Recently used [■] [■] [■] ... (tap to use now) │
│ Colors [■] [■] [■] ... (tap to use now) │
│ [‹ Backgrounds] [Close] │
└───────────────────────────────────────────────────────┘
┌ Custom picker · opened from current-color swatch ────┐
│ Preview: [wide solid color; Stage previews draft] │
│ [color field / sliders] [RGB] [HSV] [Linear] │
│ [Back] [Use color] │
└───────────────────────────────────────────────────────┘
```
Keep the Stage visually undimmed while either Plain Background color view is open, while retaining the transparent, input-blocking modal layer. In the color-choices view, Back and Close stay in the fixed footer; stack them as full-width targets on narrow windows.
The color views follow the existing rounded Scenery chooser and surface color picker visual language: large preview, readable labels, spacious swatches, visible Back, and a blue **Use color** action for the custom draft. They stay within the safe viewport and scroll their body when needed; changing views preserves the chooser's anchor so the clicked control does not jump. Swatches, cards, and actions have at least 44 × 44 logical-pixel targets and usable keyboard focus. The current choice is identified by text and outline, not color alone. The RGB/HSV/Linear controls are the existing advanced color picker behavior, not a new child-facing color model to teach.
The four Sky cards retain their current one-tap behavior. Choosing any Sky changes the scene background immediately. The scene remembers its last chosen plain color, so reopening Plain Background starts with that color and allows the child to use it again. Sky and plain color remain visual backdrops: neither appears in Stage object selection, blocks movement, or recolors Ground, walls, scenery artwork, Props, characters, or speech.
## Story and mechanics considerations
A child can use a plain color as an open visual canvas or as a deliberate mood. They can place walkable Ground and a cast later, then move the camera without revealing a backdrop edge. Sky remains the choice for a designed outdoor look with clouds, sun, moon, or stars. Switching backgrounds changes appearance alone; it does not alter actions, events, camera controls, physics, or the ordinary editability of starter pieces.
## Success criteria
1. **File → New** shows four distinguishable previews and labels: Plain Background, Open Sky, Town Street, and Living Room. Cancel preserves the existing scene; choosing Plain Background opens an unsaved scene with no Ground or placed objects and no Sky imagery.
2. A child in EDIT can choose Plain Background under Scenery → Backgrounds and immediately see the remembered fill. Preset/recent swatches apply immediately. In the custom picker, **Use color** confirms the draft, while **Back** or Cancel restores the last confirmed fill.
3. The committed color fills every camera view without an edge, gradient, sun, cloud, moon, or star. It remains visually consistent through camera pan/zoom, viewport resize, EDIT/DIRECT/PLAY, and PLAY/stop.
4. Switching to any Sky and back restores the scene's chosen plain color. Save/reopen preserves both the active background choice and that remembered color. Previously saved scenes using the neutral Sky keep their established appearance.
5. Background changes do not recolor or change the behavior of placed scenery, Ground, Props, characters, or speech. The background never intercepts Stage selection.
6. At narrow viewport sizes and with keyboard navigation, the starter cards, Backgrounds choices, color controls, and visible Back/Use/Close actions remain readable and reachable.
## Scope and exclusions
**Included:** A new Plain Background starter; the **Open Sky** label for the existing empty sky-backed starter; a scene-wide solid color background choice in EDIT; existing preset/recent swatches and full color picker presentation; clear preview and commit/cancel behavior; remembered plain color across Sky switches; save/reopen support; accurate starter and chooser previews; preservation of existing neutral-Sky scenes.
**Excluded:** New Sky motifs or customization, gradients or patterns for Plain Background, transparency, animation or directed background transitions, background colors tied to time of day, automatic contrast changes to placed objects, wall/Ground recoloring, new story mechanics, and Stage Undo/Redo. The existing Background ground and wall panels remain finite Scenery surfaces with their own separate color behavior.
## Current behavior and references
The current [Phase 19 Scenery brief](phase_19_scenery_backgrounds_surface_finishes.md) and [Scenery UI/UX specification](../specs/phase_19_scenery_backgrounds_ui_ux.md) describe three New Scene cards and four Sky choices; this addition updates those two choice sets only. The [Starter Scene Composition brief](phase_19_starter_scene_composition.md) defines the Town Street and Living Room compositions, which this addition does not revise. Follow the [Dialog Design Principles](../specs/dialog_design_principles.md) for the starter chooser and color flow.
Today, the [blank starter](../../content/stages/starters/blank.scene) contains no objects and selects `sky_neutral`. The [Sky view](../../scripts/stage/scenery/stage_sky_view.gd) draws that neutral choice as a gray gradient with sun and clouds. The [Stage asset browser](../../scripts/editors/stage/stage_asset_browser.gd) supplies the three starter entries and the four Sky cards; the [Scenery chooser](../../scripts/shared/ui/asset_selector.gd) displays them. Existing [surface color controls](../../scripts/shared/stage_ui/stage_surface_color_controls.gd) and [picker view](../../scripts/shared/stage_ui/stage_surface_color_picker_view.gd) provide a familiar color interaction. The [scene file handler](../../scripts/stage/stage_scene_io.gd) currently validates a saved Sky ID, and the [starter preview](../../scripts/stage/scenery/stage_starter_card_preview.gd) renders it. UI/UX and architecture should account for active background choice, remembered plain color, previews, and older files without changing the appearance of existing `sky_neutral` scenes.
## Dependencies, risks, and open choices
- **Grid and selection contrast:** On `#F5EFE0`, current white grid and selection lines have low contrast. The UI/UX specification calls for theme-backed contrasting treatments across light, dark, and saturated backgrounds without recoloring placed artwork.
- **Picker navigation:** The current-color chip is the sole entry to the custom picker; its focus/return behavior and the bounded layout are specified in the UI/UX document. The direct swatch, tentative custom preview, **Use color**, and Back/Cancel outcomes above are settled product behavior.
- **Previews and persistence:** The starter and Backgrounds cards must reflect the selected plain color, and save/reopen must retain the active choice plus the plain color remembered behind a Sky. Architecture should resolve the file representation and legacy migration without changing older neutral Sky scenes.
- **Visual contrast:** A light or dark child-selected background may make some artwork or EDIT overlays harder to see. UI/UX should review selection, grid, mode cues, and speech readability without silently changing the child's chosen artwork colors.
+118
View File
@@ -0,0 +1,118 @@
# Phase 19 — Plain Background: architecture specification
> **Status:** Approved design; implementation under way. This specification implements the [accepted product brief](../plans/phase_19_plain_background.md) and [UI/UX specification](phase_19_plain_background_ui_ux.md). The color-choices and custom-picker PNGs reflect the current-color chip as the sole custom-picker entry and the simple **Preview** label; the solid fill and exact labels in the UI/UX specification govern implementation.
## Scope and decisions
Plain Background is a scene-wide, opaque backdrop. It is not a Stage object, a wall panel, or Background ground. The initial color is `#F5EFE0`. File → New adds a truly empty Plain Background starter and relabels the existing neutral-Sky starter **Open Sky**. EDIT → Scenery → Backgrounds offers Plain Background beside the four existing Sky cards. A scene remembers its confirmed plain color while a Sky is active.
The approved design uses a small shared view composed of the existing `StageSkyView` and a full-rect solid `ColorRect`. `SandboxStage` owns the confirmed scene values and the short-lived picker draft. No `Resource`, global signal bus, or extra selectable node is needed for three scalar document values. The Stage inspector kit (`StageInspectorPanel`, `StagePanelChoiceGroup`, `StagePanelToggleRow`) remains for selected objects; this is a modal chooser and uses `AssetSelector`, `AssetCard`, the existing color controls, and their theme tokens.
When Sandbox Stage launches as the active scene without a requested scene, `SandboxStage` opens the starter chooser once after startup recovery handling. A restored autosave remains the active scene without a chooser; discarding recovery opens the chooser. CLI scene requests and load errors keep their existing flows. Closing the startup chooser leaves the empty EDIT Stage open and does not reopen the chooser for that session.
## Node hierarchy and rendering
```text
SandboxStage : Node2D
├─ StageBackgroundLayer : CanvasLayer (layer -1)
│ └─ StageBackgroundView : Control (full viewport; ignores mouse)
│ ├─ StageSkyView : Control (camera-bound only on the live Stage)
│ └─ PlainFill : ColorRect (full rect, opaque, ignores mouse)
├─ StageGrid : Node2D (EDIT overlay)
└─ World : Node2D (existing placed objects)
StageStarterCardPreview : SubViewportContainer
└─ PreviewViewport : SubViewport
├─ PreviewBackgroundLayer : CanvasLayer (layer -1)
│ └─ StageBackgroundView (unbound still)
└─ PreviewWorld : Node2D
AssetSelector scene-wide card
└─ StageBackgroundCardPreview : Control
└─ StageBackgroundView (unbound still, clipped to card)
```
`StageBackgroundView` toggles its Sky and Plain children exclusively. A Plain view is a single opaque viewport-sized rect, with no gradient, horizon, motif, parallax, or world transform. Its anchors respond to viewport resize. `StageSkyView` continues to own all five existing Sky IDs and camera response; when hidden for Plain it should not spend frames updating Sky motifs. The view and both children ignore mouse input and never enter Stage selection or draw-order lists. The starter preview must use the same background-kind and color interpretation as the live Stage. The gallery card receives the **remembered** plain color even when the active kind is Sky. Card frames and labels are UI overlays outside the fill, not part of its sample.
## Typed contracts and ownership
| Target | Contract and change | Owner responsibility |
| --- | --- | --- |
| `scripts/stage/scenery/stage_background_view.gd`, `class_name StageBackgroundView extends Control` | `func set_background(kind: StringName, sky_id: StringName, plain_color: Color) -> void`; `func bind_camera(camera: Camera2D) -> void`; `func apply_theme(stage_theme: SandboxTheme) -> void` | Only renders a validated Sky or opaque Plain fill. Reuses `StageSkyView`; has no document, history, or picker state. `bind_camera(null)` yields still previews. |
| `scripts/editors/stage/sandbox_stage.gd`, `class_name SandboxStage extends Node2D` | Confirmed `_background_kind: StringName`, `_sky_id: StringName`, `_plain_color: Color`; transient `_plain_color_draft_active: bool`, `_plain_color_draft: Color`. Private typed helpers such as `_commit_background_kind(kind: StringName, sky_id: StringName = &"") -> void`, `_commit_plain_color(color: Color) -> void`, `_preview_plain_color(color: Color) -> void`, `_cancel_plain_color_preview() -> void`, `_refresh_background_view() -> void`. | Sole authority for current scene state, dirty state, save snapshot, recent color history, and draft rollback. Switching to Plain changes the kind immediately and opens choices; switching Sky retains `_plain_color`. |
| `scripts/stage/stage_scene_io.gd`, `class_name StageSceneIO extends RefCounted` | `FILE_VERSION := "1.7"`; typed validation/migration of `background_kind`, `sky_id`, and `plain_color`. | Reject malformed new backdrop fields before applying a document; migrate older versions without changing their visible Sky. |
| `scripts/editors/stage/stage_scene_adapter.gd`, `class_name StageSceneAdapter extends RefCounted` | Pass all three fields through `collect(...) -> Dictionary` and `apply(...) -> Dictionary`. | Keep background data at the top level; no object entry is created. |
| `scripts/editors/stage/stage_asset_browser.gd` and `scripts/shared/ui/asset_selector.gd`, `class_name AssetSelector extends PopupPanel` | Supply four starter cards and five scene-wide background cards; pass `{background_kind, sky_id, plain_color}` for active state and previews. Add typed `signal plain_color_preview_requested(color: Color)`, `signal plain_color_commit_requested(color: Color)`, and `signal plain_color_preview_cancel_requested` through the browser facade. | The chooser owns view navigation, focus, current/selected card display, and picker controls; it emits intents. It never marks the scene dirty or writes scene data. Keep existing `surface_color_confirmed` for wall/Ground setup history; do not route Plain through it and double-record a color. |
| `scripts/shared/stage_ui/stage_surface_color_controls.gd`, `class_name StageSurfaceColorControls extends VBoxContainer`; `scripts/shared/ui/color_swatch_selector.gd`, `class_name ColorSwatchSelector extends FlowContainer` | Retain `color_selected(color: Color)` and `custom_color_requested`; activating the current-color chip is the sole entry to the full picker. Ensure compact swatches are at least 44 × 44 and stack sections when a horizontal row will clip. | Show current, recent, and preset colors with separate selected and focus treatment. The Stage's existing eight-color recent list is shared. |
| `scripts/shared/stage_ui/stage_surface_color_picker_view.gd`, `class_name StageSurfaceColorPickerView extends VBoxContainer` | Extend `configure(...)`, or add a typed background-specific configuration method, so `preview_color_changed(color: Color)` uses an opaque flat sample for Plain. | Native `ColorPicker` supplies controls. The view displays a draft but does not commit it. Surface motif previews keep their current path. |
| `scripts/stage/scenery/stage_starter_card_preview.gd` and `scripts/stage/scenery/stage_background_card_preview.gd` | Use `StageBackgroundView` for starter and background card imagery. | Show a true solid fill for Plain and preserve existing Sky rendering in still previews. |
| `scripts/stage/stage_grid.gd`, `class_name StageGrid extends Node2D`; `scripts/stage/stage_gizmos.gd`, `class_name StageGizmos extends Node2D`; `scripts/stage/sandbox_theme.gd`, `class_name SandboxTheme extends RefCounted`; `sandbox_theme.json` | Add theme-backed light/dark grid colors and two-tone editor outline colors. Add typed setters on drawing nodes if needed to pass the current backdrop treatment. | Adapt editor overlays to the background while leaving authored art, speech, and physics unchanged. |
The signal names above are the desired public interface between chooser, browser, and Stage. Keep the existing `item_selected(entry: Dictionary)` path for Sky and Plain card taps. A Plain card tap commits the active kind before the chooser opens its color-choices view. A Sky card tap commits the new Sky immediately and keeps the chooser open. The current-card indicator uses a stable **Current background** badge and selected border; keyboard focus is separate. The Plain color choices and its custom picker keep the Stage at full brightness while the modal input blocker remains active and transparent. Other chooser views retain the usual visual dimming.
## Saved scene format and migration
Save top-level fields in `.scene` v1.7:
```json
{
"version": "1.7",
"background_kind": "plain",
"sky_id": "sky_neutral",
"plain_color": "#F5EFE0",
"camera": {"position": {"x": 0.0, "y": -400.0}, "zoom": 0.5},
"objects": [],
"event_rules": []
}
```
`background_kind` is exactly `"sky"` or `"plain"`. `sky_id` remains one of the existing five IDs even while Plain is active, preserving the last selected Sky for a later switch. `plain_color` is an opaque canonical six-digit `#RRGGBB` string. Runtime color values are clamped to opacity before commit; invalid file values are rejected at the JSON boundary. The plain starter is a separate `.scene` file under `content/stages/starters/` with these values and empty `objects`/`event_rules`; the existing `blank.scene` can remain the Open Sky starter, with its UI label changed. Town Street and Living Room remain authored compositions and acquire migrated Sky-kind fields on their next save if their source version is older.
`StageSceneIO._migrate_to_current()` must explicitly handle **1.6** as well as 1.0–1.5. Every pre-1.7 file migrates to `background_kind: "sky"` and `plain_color: "#F5EFE0"`; it preserves its migrated `sky_id` (including `sky_neutral`). In particular, adding 1.6 to the old `version != "1.5"` branch would incorrectly overwrite its Sky choice: keep that earlier version-specific rule intact. Current-version normalization still runs for migrated data. Read and validate the complete document before replacing the live scene. Save and autosave both serialize confirmed fields only; a picker draft is never consulted. `ContentPaths.canonicalize()` continues to handle starter paths.
## Color transaction and navigation
```mermaid
stateDiagram-v2
[*] --> Backgrounds
Backgrounds --> ColorChoices: tap Plain / commit kind
Backgrounds --> Backgrounds: tap Sky / commit sky
ColorChoices --> ColorChoices: tap swatch / commit color
ColorChoices --> CustomPicker: activate current-color chip / snapshot confirmed color
CustomPicker --> ColorChoices: Use color / commit once
CustomPicker --> ColorChoices: Back or Esc / discard draft
ColorChoices --> Backgrounds: Back / keep commits
CustomPicker --> [*]: popup hide, mode switch, scene replacement / discard draft
```
`_plain_color` is the confirmed remembered value; `_plain_color_draft` exists only while the custom picker is open. Every native picker movement calls `_preview_plain_color()` to update the live `StageBackgroundView` and its flat chooser sample, without assigning `_plain_color`, changing recent history, or marking dirty. **Use color** clamps to opaque, commits the chosen color once, clears draft state, calls the existing `_record_recent_surface_color()` once, and returns to color choices. A preset/recent swatch uses the same commit method directly. An intentional selection can reorder recent history; mark the scene dirty only if the confirmed scene value actually changes. Opening choices at the untouched default does not add the default to recents.
Back, Cancel, Esc, popup hide, mode switch, and scene replacement must all clear the draft and restore the confirmed render. A replacement cancels the draft **before** resetting or loading scene state; popup-hide cleanup must be idempotent because a normal close can trigger it after a button callback. Back from color choices returns to Backgrounds without reverting confirmed card/swatches; Close retains confirmed choices. If Save/autosave occurs during a draft, the snapshot reads `_plain_color`, never the displayed draft. Focus returns to the Plain card from color choices and to the custom-picker opener from the picker; the popup keeps its screen anchor while switching views.
## Chooser layout and contrast
Use the existing `AssetSelector` responsive grid and `AssetCard` controls. File → New presents Plain Background, Open Sky, Town Street, Living Room in that order, two columns on a normal desktop and one scrollable column when narrow. Keep fixed heading and reachable Close. Backgrounds presents the five scene-wide cards under **Choose the scene background**; Wall panel and Background ground stay in a separate **More backgrounds** row. The color-choices view has a fixed **Choose background color** heading, flat confirmed preview, a focusable current-color chip with readable hex, up to eight shared recents, and presets. Place **‹ Backgrounds** at the left of the fixed footer and **Close** at the right; stack them as full-width actions on narrow layouts. Activating the current-color chip opens the custom picker; do not add a separate **More colors** button. The custom view has a flat draft preview and fixed Back/Use footer. Reuse `popups.asset_selector`, `popups.dialog`, `stage_surface_colors`, `stage_panels.action`, and `mode_colors.edit` tokens; add only narrowly needed flat-preview/backdrop-overlay tokens. Increase `popups.asset_selector.compact_swatch_size` from 42 to at least 44 in both theme sources, and clamp the actual `ColorSwatchSelector` target size to at least 44 even if a custom theme supplies a smaller number. Card, swatch, and action targets also meet 44 × 44. Scroll the content within viewport-safe bounds; do not horizontally clip compact color sections.
`StageGrid` currently uses translucent white lines. For Plain, choose theme-backed dark minor/major lines on a light fill and light minor/major lines on a dark fill using the displayed color's luminance, including a temporary draft. Minor lines stay subdued; major lines remain legible. On Sky, retain the established grid treatment. `StageGizmos` currently draws white selection and yellow hover outlines, which can disappear against light fills; add a dark backing stroke beneath a bright core for selection, hover, box selection, rotate ring, and scale handles. Keep screen-space widths and hit testing unchanged. This overlay treatment may be applied consistently for Sky and Plain. No authored object, speech bubble, placement material, or pixel color is rewritten. EDIT still owns grid/gizmos, DIRECT keeps its framing cues, and PLAY hides edit-only overlays. Review cursor pills and placement ghosts on light, dark, and saturated fills during rendered verification.
## Observable acceptance and verification route
| User path / repeatable scenario | Observable outcome |
| --- | --- |
| Fresh Sandbox Stage startup without a scene; close the chooser; compare with a CLI scene load and autosave restore/discard | The chooser opens once over an empty EDIT Stage. Close leaves the blank Stage open without reopening the chooser. A CLI-loaded or restored scene suppresses it; discarding autosave recovery opens it only after the recovery dialog closes. |
| Dirty scene → File → New → cancel unsaved gate or cancel starter chooser; then choose Plain and Open Sky in separate runs | Gates preserve the prior scene on cancel. Plain opens an unsaved empty scene with a uniform `#F5EFE0` fill and zero placed objects; Open Sky keeps the former neutral gradient, sun, and clouds. Both card previews match. |
| EDIT → Scenery → Backgrounds → Plain → swatch → Sky → Plain | Plain taps switch immediately, swatches update Stage and recent ordering, Sky remains selectable, and returning to Plain restores its confirmed color. Selected badge and focus are distinct. Wall/Ground remain separate. |
| Plain custom picker → drag RGB/HSV controls → Back; repeat with Esc, Close, mode change, popup dismissal, and scene replacement | Draft appears in Stage/sample while editing; each cancel path restores the prior confirmed fill. Dirty state, recent list, saved file, and autosave content do not change from the draft. Replacement does not carry draft into the next scene. |
| Plain color choices → activate current-color chip → change custom picker controls → Use color → Save → reopen; compare color and recent list before/after | The current-color chip opens the picker without a separate button. One confirmation stores an opaque color, records it once in shared history, and marks the scene dirty once. Reopen restores active kind and remembered color. A Sky-active save/reopen also retains the hidden remembered plain color. |
| Load representative v1.0–v1.6 files, especially a v1.6 `sky_neutral` scene and a v1.6 non-neutral Sky; save/reopen | They remain visually Sky scenes with the same Sky ID and composition; migration adds default remembered Plain color and writes v1.7 without changing objects, camera, or Sky choice. Invalid v1.7 background data fails before live-scene replacement. |
| Plain Stage with no world objects → pan, zoom, viewport resize, EDIT → DIRECT → PLAY → stop; repeat after save/reopen | Every frame stays an opaque edge-free flat fill. No gradient or motifs appear; backdrop never intercepts clicks. Mode transitions retain color; PLAY has no edit-only grid/gizmos. |
| Light `#F5EFE0`, dark, and saturated Plain colors with Ground, artwork, Props, character, speech, selection, and placement ghost | Grid major/minor lines, selection/hover/gizmos, cursor pills, and ghosts remain usable. Foreground pixel colors and object behavior remain unchanged. |
| Narrow viewport → pointer/touch/keyboard through starters, cards, swatches, picker, Back/Use/Close | Content scrolls without horizontal clipping; actions stay reachable; all targets meet 44 × 44; returning from subviews restores opener focus and popup anchor. |
Use the real Stage chooser, stage scene load/save path, and render-capable Stage for the scenarios above. Inspect captured frames at the named colors, camera positions, zoom levels, modes, and viewport sizes; a headless parse or a screenshot command alone does not establish visual correctness. Focused automated checks should cover the v1.7 migration/validation boundary and the commit/cancel state transitions where they meaningfully protect behavior. No new graphical or animation asset is required: thumbnails and previews are rendered from existing Sky drawing and the new solid fill.
## Trade-offs and implementation constraint
Composing a backdrop view adds one small node and typed facade but keeps Sky drawing focused and lets live Stage and previews share the same kind switch. Three scalar file fields are easier to validate and migrate than a custom `Resource`; the saved `sky_id` is deliberate remembered state while Plain is active. Color history remains a user setting shared with surface colors, while the confirmed plain color belongs to each scene. Theme-backed grid color can account for the flat background, but it cannot account for every placed object beneath a particular grid segment; the two-tone gizmo outline protects selection visibility across mixed art.
The existing chooser was designed around four Sky cards and a separate surface row. Its grid-row counting, active-card group, footer placement, and compact swatch width need targeted extension for five scene-wide choices and the new color views. Preserve its popup anchor and focus behavior while changing those branches; do not fork a second gallery or color picker.
@@ -0,0 +1,99 @@
# Phase 19 — Plain Background: UI/UX specification
> **Status:** UI/UX direction revised per user feedback from the user-approved PNG mockups. The current-color chip is the sole entry to the custom picker; there is no separate **More colors** button. The default color is approved as warm off-white `#F5EFE0`; the color swatches and sample views must show a flat fill.
>
> **Design references:** [Phase 19 Plain Background brief](../plans/phase_19_plain_background.md), [approved PNG mockups](../plans/assets/phase_19_plain_background/), [Phase 19 Scenery UI/UX specification](phase_19_scenery_backgrounds_ui_ux.md), and [Child-Facing Dialog Design Principles](dialog_design_principles.md).
## Child promise
A child can start with an empty stage filled by one color, choose another color in EDIT, and return to that color after trying a Sky. The color fills the whole camera view. It does not create a selectable object or change the colors and behavior of placed pieces.
## File → New
- Keep the existing unsaved-work Save/Discard/Cancel gate. Do not replace the current scene until a starter card is chosen.
- Use the existing themed `AssetSelector` shell and `AssetCard` presentation with a fixed **Choose a starter scene** heading, a scrollable responsive card body, and a reachable visible **Close** action. The card order and tab order are **Plain Background**, **Open Sky**, **Town Street**, **Living Room**.
- At desktop widths, show an equal-sized 2 × 2 card grid. At narrow widths, wrap to one column and scroll the body while keeping the title and Close action available. Preserve the popup's screen anchor when its layout changes.
- Make this chooser materially larger than the current roughly 660 × 560 logical-pixel asset selector: target about 1160 logical pixels wide on a roomy desktop, with a natural height that shows both card rows and the Close action. Cap both dimensions to the usable viewport with safe margins; a short display scrolls the card body while the title and Close stay reachable. At the preferred width, each card's preview should be about 500 pixels wide and at least 240 pixels tall, occupying roughly two-thirds of the card height. Scale the preview with its card instead of leaving a small fixed thumbnail inside a large tile. The [larger starter chooser mockup](../plans/assets/phase_19_plain_background/05_large_starter_chooser.png) shows the intended balance; its pixel dimensions are illustrative, not a fixed window size.
- Plain Background's thumbnail is a uniform opaque `#F5EFE0` fill with no horizon, gradient, Sky motif, checkerboard, or object. Its copy is: **“An empty stage with one color. Choose a new color whenever you like.”** Starting it creates a new unsaved scene with no Ground or placed objects and no additional setup step.
- Open Sky previews the existing neutral gradient, sun, and clouds. Its copy is: **“An empty stage with a soft sky. Sun and clouds, ready for your story.”** This is the existing empty neutral-Sky starter under a clearer name.
- Town Street and Living Room retain their authored compositions and existing descriptions.
- Activating a card by pointer, touch, Enter, or Space opens that starter. Close or Escape leaves the current scene intact.
## Fresh Sandbox startup
- When the Sandbox Stage launches as the active scene without a requested scene, show **Choose a starter scene** once for that Stage session. This gives children the same clear starting point as File → New.
- If an autosave is available, resolve its recovery prompt first. Restoring it opens the recovered scene without the starter chooser; discarding it opens the chooser afterward.
- A command-line scene load or load error does not open the starter chooser. The chooser must not cover recovery or another modal dialog.
- Close or Escape leaves the empty EDIT Stage available. Do not automatically reopen the chooser during that session; File → New remains available when the child wants another starter.
## EDIT → Scenery → Backgrounds
- Extend the current `AssetSelector` Backgrounds tab with a **Plain Background** card alongside **Clear Day**, **Cloudy Day**, **Sunset**, and **Starry Night**. Keep **Wall panel** and **Background ground** visually separated under a **More backgrounds** row.
- Show the heading **Choose the scene background** above the five scene-wide choices. The Plain Background card preview uses the remembered plain color even while a Sky is active.
- Mark the active choice with the existing cyan selected fill/border and a stable **Current background** badge. Keep the keyboard focus outline visually distinct from selection. Do not identify the current choice by color alone.
- Sky cards retain their immediate selection behavior and leave the chooser open. Activating Plain Background immediately restores/applies its remembered color and opens the Plain Background color choices. Back or Close from those choices keeps Plain Background active.
- Neither a Sky nor Plain Background is Stage-selectable or included in Pieces here. Switching background never starts placement or changes the current cursor mode.
## Plain Background color choices
- Reuse the bounded chooser shell, `StageSurfaceColorControls` and shared `ColorSwatchSelector` visual language; the full-stage preview and scene-specific copy are the only feature-specific presentation.
- Keep the **Choose background color** heading. Put **‹ Backgrounds** in the fixed footer, left of **Close**, instead of in the title row. Both are large, outlined secondary actions with 12–16 px separation; at narrow widths, stack them vertically as full-width targets. The scrollable body contains:
1. Helper text: **“Tap a color to use it on the Stage.”**
2. A large, flat, opaque preview of the confirmed color with no text over the color sample.
3. The current color swatch and readable hex value.
4. **Recently used** colors, using the shared recent color list (up to eight).
5. **Colors** preset swatches.
- If recents are empty, show **“Colors you use will appear here.”** Opening Plain Background at the untouched default does not add that default to recents.
- Tapping a recent or preset swatch immediately confirms it. The full Stage, preview, current swatch, selected outline/check, dirty state, and recent ordering update together. Leaving and reopening the view preserves that confirmed choice.
- Give the selected swatch an outline/check that is distinct from keyboard focus. Make all swatches at least 44 × 44 logical pixels, including compact layouts; the current 42-pixel compact swatch default is too small here.
- The current-color chip is the sole entry point to the full custom picker. It is a focusable button with clear hover, pressed, and focus states and the tooltip **“Choose a custom color.”** Activating the chip opens the picker; there is no separate **More colors** button.
- Keep the Stage at full brightness while Plain Background color choices or its custom picker are open so live color changes can be judged accurately. Keep the modal input-blocking layer active but visually transparent; clicks outside the dialog must not reach the Stage. The dialog keeps its opaque shell, outline, and footer for modal clarity. Other chooser views retain the normal dim backdrop.
## Full custom picker
- Reuse/extend `StageSurfaceColorPickerView`, its native `ColorPicker`, large preview, theme, and compact-height behavior. Use a flat, opaque preview matching the Stage with no text overlay.
- Use the heading **Choose background color** and a simple **Preview** label above the large color sample. The tentative behavior is communicated by the Stage updating during picker movement and the visible **Use color** / **Back** actions; no explanatory preview message is needed.
- On open, snapshot the last confirmed plain color. Moving native color controls updates only the temporary Stage preview and large sample. It does not change history, scene dirty state, or serialized data.
- Use a fixed, visible footer with a dark secondary **Back** (or **Cancel**) button and a blue, bold, white **Use color** primary button, separated by 12–16 logical pixels. All actions remain at least 44 × 44 logical pixels.
- **Use color** confirms once, updates the remembered color and recent history once, marks the scene dirty once, and returns to the color choices.
- Back, Cancel, Escape, or closing the picker restores the confirmed snapshot and returns to color choices with Plain Background still active.
- Mode changes, scene replacement, or unexpected popup dismissal also clear a temporary preview and restore the confirmed color. A temporary color must never enter Save or autosave.
## Focus, layout, and theme
- Use `SandboxTheme` values from `popups.asset_selector`, `popups.dialog`, `stage_surface_colors`, `stage_panels.action`, and `mode_colors.edit`. Add a small Plain-preview token group only if the existing theme has no suitable values; avoid a parallel swatch or picker system.
- Keep cards, swatches, and actions at least 44 × 44 logical pixels. Preserve the existing dialog style: rounded surfaces, visible outlines, readable type, blue primary action, and labeled Close/Back/Use actions.
- Tab order: starter cards → Close; Scenery tabs → scene-background cards → surface cards → Close; color choices: Back → current-color chip → recent swatches → preset swatches → footer; custom picker → Back → Use color.
- Opening a subview moves focus to its heading or first useful action. Returning from the color choices restores focus to Plain Background; returning from the custom picker restores focus to the current-color chip.
- Keep the title and footer actions reachable while the body scrolls. Cap the popup to the safe viewport; do not force clipping or horizontal scrolling to retain compact horizontal swatch columns. Stack the Back/Close footer actions and current/recent/preset sections at narrow widths. Preserve the popup anchor when switching gallery, color, and custom-picker views.
- Pointer, touch, and keyboard users get the same selected, hover, focus, and confirmation feedback. Clicking outside must not silently confirm a tentative custom color.
## Canvas contrast and feedback
- Review white, black, and saturated Plain Background colors. On light fills such as `#F5EFE0`, the current white EDIT grid and white selection outlines have about 1.15:1 contrast and nearly disappear. Provide a theme-backed contrasting grid treatment for light and dark fills, keeping minor lines subdued and major lines legible.
- Give Stage selection, hover, and gizmo outlines a dark backing plus bright core on Plain Backgrounds of any brightness, following the existing two-tone selection-halo practice. Do not recolor authored artwork.
- Keep EDIT chrome and mode pill dark-backed with cyan accents, DIRECT framing amber, and PLAY free of edit-only grid and gizmos. Preserve speech styles and their authored colors. Check cursor pills and placement ghosts at light, dark, and saturated backgrounds.
- A Plain Background color is a scene-wide visual setting only: it never intercepts Stage selection or changes object ordering, placement, action behavior, or camera movement.
## Acceptance scenarios
1. Open Sandbox Stage without a scene and verify the starter chooser appears. Close it and verify the empty EDIT Stage remains available without another automatic prompt in that session. Open a scene through the CLI and verify the chooser does not appear.
2. If an autosave is available at startup, restore it and verify the chooser stays closed; discard it and verify the chooser appears afterward without overlapping the recovery prompt.
3. In a dirty scene, use File → New and verify the existing unsaved gate appears first. Cancel the starter chooser and confirm the previous scene remains. Choose Plain Background and verify the new unsaved Stage is a single flat `#F5EFE0` with no Sky, Ground, or placed objects. Verify Open Sky reproduces the existing neutral Sky appearance.
4. In EDIT, open Scenery → Backgrounds. Verify all five scene-wide choices are visible, the current choice is identified with text and a border, and Wall panel/Background ground remain separate. Choose Plain Background and verify it opens with the remembered color.
5. Tap one preset and one recent swatch. For each, verify the Stage and preview update immediately, the color becomes selected, and recent ordering updates. Close and reopen the choices and verify the confirmed value remains.
6. Activate the current-color chip to open the custom picker. Move a color control, then choose Back. Verify the Stage and preview return to the last confirmed color and the scene/recent history remain unchanged. Repeat and choose Use color; verify the choice and history update once and remain after Save/reopen.
7. Repeat custom-picker cancellation through Escape, visible Cancel/Back, close, mode change, and scene replacement. No temporary preview may leak into the next Stage or saved scene.
8. With each of Sky and Plain active, pan, zoom, resize the viewport, enter/stop PLAY, and reopen a saved scene. Verify the solid fill covers the camera view with no edge and that the remembered plain color returns after switching back from Sky.
9. On light, dark, and saturated fills, inspect grid, selection, hover, gizmos, cursor pills, placement ghosts, speech, and mode chrome. Confirm the Stage remains readable and placed artwork colors remain unchanged.
10. At narrow viewport sizes, navigate each card, swatch, and action by pointer, touch, and keyboard. Verify the content scrolls without clipping; focus and selection remain distinct; Back/Use/Close remain visible; returning from subviews restores the opener focus and popup anchor.
## Reuse boundary
| Surface | Reuse direction |
| --- | --- |
| Starter and Scenery cards | Extend `AssetSelector` and `AssetCard`; use `StageBackgroundCardPreview` for a real solid-color thumbnail and add the Plain-specific label/selection state. Do not create another card gallery. |
| Color choices and recents | Reuse `StageSurfaceColorControls` and `ColorSwatchSelector`/shared history. Extend layout for 44-pixel minimum targets and narrow layouts instead of introducing a parallel swatch system. |
| Custom picker | Reuse `StageSurfaceColorPickerView` and the native `ColorPicker`; give the scene-wide background its own flat preview and explicit temporary/confirm/cancel lifecycle. |
| Stage contrast | Use `SandboxTheme` tokens and the existing two-tone selection halo pattern; do not mutate user-authored object colors or make a second editor theme. |
@@ -96,6 +96,7 @@ These are relationship examples, not fixed pixel geometry. On a narrow viewport
### Stage palette and Scenery chooser ### Stage palette and Scenery chooser
- Add one illustrated **Scenery** card to the existing vertically scrollable left palette. Keep **Props** and **Ground** as separate cards, with a short helper line in their chooser/tool: “Stays put”, “Can be part of the action”, or “Stickmen walk here.” The palette card opens the Scenery chooser rather than directly arming a tool. - Add one illustrated **Scenery** card to the existing vertically scrollable left palette. Keep **Props** and **Ground** as separate cards, with a short helper line in their chooser/tool: “Stays put”, “Can be part of the action”, or “Stickmen walk here.” The palette card opens the Scenery chooser rather than directly arming a tool.
- Keep the Scenery card pressed while its chooser and nested views are open. Back navigation keeps it pressed; closing or canceling the full chooser clears it. If a choice starts drawing, show that active state with the existing on-Stage capture bar instead of leaving the chooser card pressed.
- The chooser has a fixed title/Close row; **Backgrounds** and **Artwork** tabs; a scrollable body; and a fixed lower **Make artwork…** action when relevant. It is a chooser workflow, not a selected-object inspector. It receives `SandboxTheme.control_theme()` and its own popup tokens, while borrowing the Stage panel system's font, surface, selected, hover, focus, and target-size rules. - The chooser has a fixed title/Close row; **Backgrounds** and **Artwork** tabs; a scrollable body; and a fixed lower **Make artwork…** action when relevant. It is a chooser workflow, not a selected-object inspector. It receives `SandboxTheme.control_theme()` and its own popup tokens, while borrowing the Stage panel system's font, surface, selected, hover, focus, and target-size rules.
- **Backgrounds** shows two large category choices, **Sky** and **Wall panel**. **Artwork** shows a single-select filter row with **All artwork**, **Nature**, **Buildings**, **Walls**, **Roads & paths**, **Objects**, and conditional **Unsorted**. One drawing may carry several tags, so it appears under every matching filter. All artwork includes old, untagged drawings. Filters describe appearance, not behavior. Apply the same filters in the Props browser while keeping its title and placement role distinct. - **Backgrounds** shows two large category choices, **Sky** and **Wall panel**. **Artwork** shows a single-select filter row with **All artwork**, **Nature**, **Buildings**, **Walls**, **Roads & paths**, **Objects**, and conditional **Unsorted**. One drawing may carry several tags, so it appears under every matching filter. All artwork includes old, untagged drawings. Filters describe appearance, not behavior. Apply the same filters in the Props browser while keeping its title and placement role distinct.
- Use a `FlowContainer` for wrapping filter buttons and an adaptive card grid for previews. Each card has a large illustration, a readable name, and a visible keyboard focus ring. No card depends on hover to reveal its action. Changing tabs or tags preserves the chooser and moves focus to the first relevant control; closing returns focus to the Scenery palette card. - Use a `FlowContainer` for wrapping filter buttons and an adaptive card grid for previews. Each card has a large illustration, a readable name, and a visible keyboard focus ring. No card depends on hover to reveal its action. Changing tabs or tags preserves the chooser and moves focus to the first relevant control; closing returns focus to the Scenery palette card.
@@ -285,3 +286,4 @@ Do not expose “entity”, “collision hull”, “z-index”, “physics laye
7. In Living Room, use Select several to choose two wall panels, the window frame, and rug. Preview a shared move, cancel with right-click, and verify all four return exactly to their original locations while Wood Ground and furniture remain still. Preview a uniform corner resize, check the opposite anchor stays fixed and wall motifs do not stretch, then Keep changes; save and reopen. The four pieces retain their new positions/sizes and original depth/finish, while the temporary group selection is gone. Repeat the preview with touch or keyboard controls in a narrow viewport, using Esc to cancel. 7. In Living Room, use Select several to choose two wall panels, the window frame, and rug. Preview a shared move, cancel with right-click, and verify all four return exactly to their original locations while Wood Ground and furniture remain still. Preview a uniform corner resize, check the opposite anchor stays fixed and wall motifs do not stretch, then Keep changes; save and reopen. The four pieces retain their new positions/sizes and original depth/finish, while the temporary group selection is gone. Repeat the preview with touch or keyboard controls in a narrow viewport, using Esc to cancel.
8. Save a scene with two copies of one live `.prop` Scenery drawing, then make the file unavailable and reopen the scene. The friendly missing-art summary appears once; both labeled markers remain at their saved positions/depths through EDIT and PLAY. In ordinary EDIT, select a character in front of a marker without selecting Scenery. Use a marker's Find artwork badge or the Edit Scenery **Needs artwork** list to open its card. Cancel a file choice and verify both markers remain. Choose a replacement for one copy, preview then cancel once, then confirm it; only that copy changes. Confirm the second still has a marker after save/reopen until it too is repaired or deliberately erased. Repeat the repair path with keyboard and on a narrow touch viewport. 8. Save a scene with two copies of one live `.prop` Scenery drawing, then make the file unavailable and reopen the scene. The friendly missing-art summary appears once; both labeled markers remain at their saved positions/depths through EDIT and PLAY. In ordinary EDIT, select a character in front of a marker without selecting Scenery. Use a marker's Find artwork badge or the Edit Scenery **Needs artwork** list to open its card. Cancel a file choice and verify both markers remain. Choose a replacement for one copy, preview then cancel once, then confirm it; only that copy changes. Confirm the second still has a marker after save/reopen until it too is repaired or deliberately erased. Repeat the repair path with keyboard and on a narrow touch viewport.
9. In Prop Editor, open **Size for Stage** on representative tall, wide, and small artwork. Confirm the standard stickman is drawn in front, the floor/contact guide is visible over every fill, the preview frames both together, presets and fine adjustments preserve proportions, **Keep size** applies, and **✕ Cancel** restores the exact prior geometry. Confirm new placement uses the authored size and loading an existing file performs no automatic normalization. Deliberately save revised geometry over a referenced asset and confirm the usual Save flow and live-reference update on reopen, with scene placement transforms retained. In Edit Scenery, resize one placement and confirm it commits on release and saves/reopens; cancel a still-active drag with Escape/right-click and with the touch capture bar; verify other scenery and Props stay unchanged. Compare this with the separate group Keep/Cancel flow. Repeat sizing-guide visibility and Stage handle/button access with keyboard/touch and at a narrow viewport. 9. In Prop Editor, open **Size for Stage** on representative tall, wide, and small artwork. Confirm the standard stickman is drawn in front, the floor/contact guide is visible over every fill, the preview frames both together, presets and fine adjustments preserve proportions, **Keep size** applies, and **✕ Cancel** restores the exact prior geometry. Confirm new placement uses the authored size and loading an existing file performs no automatic normalization. Deliberately save revised geometry over a referenced asset and confirm the usual Save flow and live-reference update on reopen, with scene placement transforms retained. In Edit Scenery, resize one placement and confirm it commits on release and saves/reopens; cancel a still-active drag with Escape/right-click and with the touch capture bar; verify other scenery and Props stay unchanged. Compare this with the separate group Keep/Cancel flow. Repeat sizing-guide visibility and Stage handle/button access with keyboard/touch and at a narrow viewport.
10. Open Scenery and navigate between Backgrounds, Plain Background color choices, and its custom picker. Back keeps the Scenery card pressed; Close or Escape from the full chooser clears it. Choose an artwork or surface tool and confirm the chooser card is unpressed while the on-Stage capture bar shows the active tool.
+28 -2
View File
@@ -77,7 +77,13 @@
"sideways_offset": 4.0 "sideways_offset": 4.0
} }
}, },
"grid": { "snap_size": 15.0 }, "grid": {
"snap_size": 15.0,
"plain_light_minor": "#11182120",
"plain_light_major": "#11182148",
"plain_dark_minor": "#FFFFFF25",
"plain_dark_major": "#FFFFFF58"
},
"chrome": { "chrome": {
"style_defaults": { "bg_color": "#171B24F2", "corner_radius": 10 }, "style_defaults": { "bg_color": "#171B24F2", "corner_radius": 10 },
"top_bar": { "height": 64 }, "top_bar": { "height": 64 },
@@ -161,8 +167,21 @@
"surface_corner_radius": 14, "surface_corner_radius": 14,
"look_corner_radius": 8, "look_corner_radius": 8,
"corner_radius": 16, "corner_radius": 16,
"compact_swatch_size": 42, "compact_swatch_size": 44,
"color_group_gap": 8, "color_group_gap": 8,
"starter_dialog_width": 1160,
"starter_viewport_height_ratio": 0.96,
"starter_card_min_width": 340,
"starter_preview_aspect": 2.0,
"starter_preview_corner_radius": 12,
"starter_preview_horizontal_inset": 10,
"starter_preview_top_inset": 6,
"starter_card_text_height": 108,
"starter_title_size": 30,
"starter_label_size": 22,
"starter_label_height": 34,
"starter_description_size": 20,
"starter_description_height": 48,
"action_color": "#087DBA", "action_color": "#087DBA",
"separator_color": "#AAB2C0A0" "separator_color": "#AAB2C0A0"
} }
@@ -287,6 +306,13 @@
"uncertain_color": "#FFB300", "uncertain_color": "#FFB300",
"neutral_color": "#C5CAD4", "neutral_color": "#C5CAD4",
"completion_duration": 0.6 "completion_duration": 0.6
},
"gizmos": {
"backing_color": "#111821E8",
"selection_color": "#F5F7FAE6",
"hover_color": "#FFE66DCC",
"rotate_color": "#4DB9FFE6",
"backing_extra_width": 3.0
} }
}, },
"widgets": { "widgets": {
+204 -25
View File
@@ -50,7 +50,7 @@ const STAGE_MODAL_VIEWS_SCRIPT := preload("res://scripts/editors/stage/stage_mod
const STAGE_THEME_CONTROLLER_SCRIPT := preload("res://scripts/editors/stage/stage_theme_controller.gd") const STAGE_THEME_CONTROLLER_SCRIPT := preload("res://scripts/editors/stage/stage_theme_controller.gd")
const STAGE_TARGET_CAPTURE_SCRIPT := preload("res://scripts/editors/stage/stage_target_capture_session.gd") const STAGE_TARGET_CAPTURE_SCRIPT := preload("res://scripts/editors/stage/stage_target_capture_session.gd")
const STAGE_SCENERY_CONTROLLER_SCRIPT := preload("res://scripts/editors/stage/stage_scenery_controller.gd") const STAGE_SCENERY_CONTROLLER_SCRIPT := preload("res://scripts/editors/stage/stage_scenery_controller.gd")
const STAGE_SKY_VIEW_SCRIPT := preload("res://scripts/stage/scenery/stage_sky_view.gd") const STAGE_BACKGROUND_VIEW_SCRIPT := preload("res://scripts/stage/scenery/stage_background_view.gd")
const STAGE_DRAW_ORDER_SCRIPT := preload("res://scripts/stage/stage_draw_order.gd") const STAGE_DRAW_ORDER_SCRIPT := preload("res://scripts/stage/stage_draw_order.gd")
const STAGE_WALL_PANEL_SCRIPT := preload("res://scripts/stage/scenery/stage_wall_panel.gd") const STAGE_WALL_PANEL_SCRIPT := preload("res://scripts/stage/scenery/stage_wall_panel.gd")
const STAGE_BACKGROUND_GROUND_SCRIPT := preload("res://scripts/stage/scenery/stage_background_ground.gd") const STAGE_BACKGROUND_GROUND_SCRIPT := preload("res://scripts/stage/scenery/stage_background_ground.gd")
@@ -258,13 +258,21 @@ var _spawner: StageSpawner
var _selection: StageSelection var _selection: StageSelection
var _gizmos: StageGizmos var _gizmos: StageGizmos
var _stage_input_ready: bool = false var _stage_input_ready: bool = false
var _startup_scene_applied: bool = false
var _startup_starter_chooser_pending: bool = false
var _startup_starter_chooser_shown: bool = false
var _grid: StageGrid var _grid: StageGrid
var _spatial_index: StageSpatialIndex var _spatial_index: StageSpatialIndex
var _terrain_painter: StageTerrainPainter var _terrain_painter: StageTerrainPainter
var _scenery_controller: StageSceneryController var _scenery_controller: StageSceneryController
var _sky_layer: CanvasLayer var _sky_layer: CanvasLayer
var _sky_view: StageSkyView var _sky_view: StageSkyView
var _background_view: StageBackgroundView
var _sky_id: StringName = &"sky_neutral" var _sky_id: StringName = &"sky_neutral"
var _background_kind: StringName = &"sky"
var _plain_color: Color = Color("#F5EFE0")
var _plain_color_draft_active: bool = false
var _plain_color_draft: Color = Color("#F5EFE0")
var _new_ground_finish: StringName = &"finish_ground_grass" var _new_ground_finish: StringName = &"finish_ground_grass"
var _hosted_prop_editor: PropEditor var _hosted_prop_editor: PropEditor
var _hosted_artwork_path: String = "" var _hosted_artwork_path: String = ""
@@ -1850,6 +1858,8 @@ func set_mode(mode: StageMode) -> void:
_show_toast("Finish or cancel speech editing first.") _show_toast("Finish or cancel speech editing first.")
_sync_mode_buttons() _sync_mode_buttons()
return return
if _plain_color_draft_active:
_close_selector()
_cancel_surface_color_preview() _cancel_surface_color_preview()
if _scenery_controller != null: if _scenery_controller != null:
if _scenery_controller.is_group_preview_pending(): if _scenery_controller.is_group_preview_pending():
@@ -2513,6 +2523,74 @@ func _mark_scene_dirty() -> void:
_paused_edit_autosave_remaining = 1.0 _paused_edit_autosave_remaining = 1.0
func _refresh_background_view() -> void:
if _background_view != null:
var displayed_color: Color = _plain_color_draft if _plain_color_draft_active else _plain_color
_background_view.set_background(_background_kind, _sky_id, displayed_color)
_sky_view = _background_view.get_sky_view()
_update_grid_background_style()
func _commit_background_kind(kind: StringName, sky_id: StringName = &"") -> void:
var next_kind: StringName = &"plain" if kind == &"plain" else &"sky"
var next_sky: StringName = sky_id if not sky_id.is_empty() else _sky_id
var changed: bool = _background_kind != next_kind or _sky_id != next_sky
_background_kind = next_kind
_sky_id = next_sky
_refresh_background_view()
if _asset_browser != null:
_asset_browser.set_background_state(_background_kind, _sky_id, _plain_color)
if changed:
_mark_scene_dirty()
func _preview_plain_color(color: Color) -> void:
_plain_color_draft = _opaque_stage_color(color)
_plain_color_draft_active = true
_refresh_background_view()
func _cancel_plain_color_preview() -> void:
if not _plain_color_draft_active:
return
_plain_color_draft_active = false
_plain_color_draft = _plain_color
_refresh_background_view()
func _commit_plain_color(color: Color) -> void:
var next_color: Color = _opaque_stage_color(color)
var changed: bool = _canonical_surface_color(_plain_color) != _canonical_surface_color(next_color)
_plain_color = next_color
_plain_color_draft = next_color
_plain_color_draft_active = false
_refresh_background_view()
_record_recent_surface_color(next_color)
if _asset_browser != null:
_asset_browser.set_background_state(_background_kind, _sky_id, _plain_color)
if changed:
_mark_scene_dirty()
func _opaque_stage_color(color: Color) -> Color:
return Color(color.r, color.g, color.b, 1.0)
func _update_grid_background_style() -> void:
if _grid == null:
return
var displayed_color: Color = _plain_color_draft if _plain_color_draft_active else _plain_color
var plain_active: bool = _background_kind == &"plain"
_grid.set_background_treatment(
plain_active,
displayed_color,
_sandbox_theme.color("grid.plain_light_minor", Color("#11182120")) if _sandbox_theme != null else Color("#11182120"),
_sandbox_theme.color("grid.plain_light_major", Color("#11182148")) if _sandbox_theme != null else Color("#11182148"),
_sandbox_theme.color("grid.plain_dark_minor", Color("#FFFFFF25")) if _sandbox_theme != null else Color("#FFFFFF25"),
_sandbox_theme.color("grid.plain_dark_major", Color("#FFFFFF58")) if _sandbox_theme != null else Color("#FFFFFF58")
)
func _set_scene_dirty(value: bool) -> void: func _set_scene_dirty(value: bool) -> void:
if _document != null: if _document != null:
_document.set_dirty(value) _document.set_dirty(value)
@@ -2533,6 +2611,8 @@ func _collect_scene_data(is_autosave: bool = false) -> Dictionary:
var document_metadata: Dictionary = { var document_metadata: Dictionary = {
"scene_name": _scene_name, "scene_name": _scene_name,
"sky_id": String(_sky_id), "sky_id": String(_sky_id),
"background_kind": String(_background_kind),
"plain_color": _canonical_surface_color(_plain_color),
"metadata": _document.metadata_for_snapshot(is_autosave), "metadata": _document.metadata_for_snapshot(is_autosave),
} }
return _scene_adapter.collect(_world, _authored, _event_rules, camera_state, document_metadata) return _scene_adapter.collect(_world, _authored, _event_rules, camera_state, document_metadata)
@@ -2613,6 +2693,7 @@ func _validate_queues_for_save() -> String:
func _reset_scene_content() -> void: func _reset_scene_content() -> void:
set_mode(StageMode.EDIT) set_mode(StageMode.EDIT)
_cancel_plain_color_preview()
_cancel_surface_color_preview() _cancel_surface_color_preview()
if _scenery_erase_piece_dialog != null: if _scenery_erase_piece_dialog != null:
_scenery_erase_piece_dialog.hide() _scenery_erase_piece_dialog.hide()
@@ -2622,8 +2703,9 @@ func _reset_scene_content() -> void:
_cancel_scenery_repair_preview() _cancel_scenery_repair_preview()
_scenery_repair_target = null _scenery_repair_target = null
_sky_id = &"sky_neutral" _sky_id = &"sky_neutral"
if _sky_view != null: _background_kind = &"sky"
_sky_view.set_sky(_sky_id) _plain_color = Color("#F5EFE0")
_refresh_background_view()
if _scenery_controller != null: if _scenery_controller != null:
_scenery_controller.exit_tool() _scenery_controller.exit_tool()
_scenery_controller.cancel_group() _scenery_controller.cancel_group()
@@ -2655,11 +2737,19 @@ func _apply_scene_data(data: Dictionary, source_path: String, is_recovery: bool)
source_path = CONTENT_PATHS.canonicalize(source_path) source_path = CONTENT_PATHS.canonicalize(source_path)
if _scene_adapter == null: if _scene_adapter == null:
return false return false
if _plain_color_draft_active:
_close_selector()
_cancel_plain_color_preview()
var was_suppressed: bool = _suppress_dirty var was_suppressed: bool = _suppress_dirty
_suppress_dirty = true _suppress_dirty = true
_reset_scene_content() _reset_scene_content()
var adapter_result: Dictionary = _scene_adapter.apply(data, _world, _spawner) var adapter_result: Dictionary = _scene_adapter.apply(data, _world, _spawner)
_sky_id = StringName(String(adapter_result.get("sky_id", "sky_neutral"))) _sky_id = StringName(String(adapter_result.get("sky_id", "sky_neutral")))
_background_kind = StringName(String(adapter_result.get("background_kind", "sky")))
_plain_color = STAGE_SCENE_IO.color_from_data(
adapter_result.get("plain_color", STAGE_SCENE_IO.DEFAULT_PLAIN_COLOR),
Color("#F5EFE0")
)
var loaded_nodes: Array[Node2D] = adapter_result.get("loaded_nodes", []) var loaded_nodes: Array[Node2D] = adapter_result.get("loaded_nodes", [])
for node: Node2D in loaded_nodes: for node: Node2D in loaded_nodes:
_finalize_placed_node(node) _finalize_placed_node(node)
@@ -2683,8 +2773,7 @@ func _apply_scene_data(data: Dictionary, source_path: String, is_recovery: bool)
var camera_data: Dictionary = raw_camera as Dictionary if raw_camera is Dictionary else {} var camera_data: Dictionary = raw_camera as Dictionary if raw_camera is Dictionary else {}
_camera.global_position = STAGE_SCENE_IO.data_to_vector(camera_data.get("position"), DEFAULT_CAMERA_POSITION) _camera.global_position = STAGE_SCENE_IO.data_to_vector(camera_data.get("position"), DEFAULT_CAMERA_POSITION)
_camera.zoom = Vector2.ONE * clampf(float(camera_data.get("zoom", DEFAULT_CAMERA_ZOOM)), min_zoom, max_zoom) _camera.zoom = Vector2.ONE * clampf(float(camera_data.get("zoom", DEFAULT_CAMERA_ZOOM)), min_zoom, max_zoom)
if _sky_view != null: _refresh_background_view()
_sky_view.set_sky(_sky_id)
var raw_metadata: Variant = data.get("metadata", {}) var raw_metadata: Variant = data.get("metadata", {})
var metadata: Dictionary = raw_metadata as Dictionary if raw_metadata is Dictionary else {} var metadata: Dictionary = raw_metadata as Dictionary if raw_metadata is Dictionary else {}
if _document != null: if _document != null:
@@ -2712,6 +2801,7 @@ func _apply_scene_data(data: Dictionary, source_path: String, is_recovery: bool)
_add_recent_scene(source_path) _add_recent_scene(source_path)
if _document != null: if _document != null:
_document.remove_autosave() _document.remove_autosave()
_startup_scene_applied = true
return true return true
func _show_scene_load_warnings(warnings: Array[String]) -> void: func _show_scene_load_warnings(warnings: Array[String]) -> void:
@@ -2782,20 +2872,79 @@ func _update_scene_chrome() -> void:
_refresh_status() _refresh_status()
func _check_autosave_recovery() -> void: func _check_autosave_recovery(show_starter_chooser_after_discard: bool = false) -> void:
if _document == null: if _document == null:
if show_starter_chooser_after_discard:
_queue_startup_starter_chooser()
return return
var inspection: Dictionary = _document.inspect_autosave() var inspection: Dictionary = _document.inspect_autosave()
if not bool(inspection.get("available", false)): if not bool(inspection.get("available", false)):
if show_starter_chooser_after_discard:
_queue_startup_starter_chooser()
return return
var autosave_data: Dictionary = inspection.get("data", {}) as Dictionary var autosave_data: Dictionary = inspection.get("data", {}) as Dictionary
var dialog := ConfirmationDialog.new() var dialog := ConfirmationDialog.new()
dialog.name = "AutosaveRecoveryDialog"; dialog.title = "Recover Sandbox Scene?"; dialog.dialog_text = "A previous Play session was not closed cleanly. Recover it?" dialog.name = "AutosaveRecoveryDialog"; dialog.title = "Recover Sandbox Scene?"; dialog.dialog_text = "A previous Play session was not closed cleanly. Recover it?"
dialog.confirmed.connect(func() -> void: _apply_scene_data(autosave_data, AUTOSAVE_PATH, true); dialog.queue_free()) dialog.confirmed.connect(func() -> void: _apply_scene_data(autosave_data, AUTOSAVE_PATH, true); dialog.queue_free())
dialog.canceled.connect(func() -> void: _document.remove_autosave(); dialog.queue_free()) dialog.canceled.connect(func() -> void:
_document.remove_autosave()
dialog.queue_free()
if show_starter_chooser_after_discard:
_queue_startup_starter_chooser()
)
get_node(NodePath("UI")).add_child(dialog); _apply_dialog_theme(dialog); dialog.popup_centered() get_node(NodePath("UI")).add_child(dialog); _apply_dialog_theme(dialog); dialog.popup_centered()
func _queue_startup_starter_chooser() -> void:
if _startup_starter_chooser_pending or _startup_starter_chooser_shown:
return
_startup_starter_chooser_pending = true
call_deferred("_present_startup_starter_chooser")
func _present_startup_starter_chooser() -> void:
while _startup_starter_chooser_pending and is_inside_tree():
if not _stage_input_ready or _startup_modal_is_visible():
await get_tree().process_frame
continue
if get_tree().current_scene != self or _startup_scene_applied or current_mode != StageMode.EDIT or not _current_scene_path.is_empty() or _hosted_prop_editor != null:
_startup_starter_chooser_pending = false
return
_startup_starter_chooser_pending = false
_startup_starter_chooser_shown = true
_open_selector("starters")
return
_startup_starter_chooser_pending = false
func _startup_modal_is_visible() -> bool:
if _selector_open or _speech_composer_is_open():
return true
var ui_layer: CanvasLayer = _chrome.get_canvas_layer() if _chrome != null else null
if ui_layer != null:
for child: Node in ui_layer.get_children():
var window := child as Window
if window != null and window.visible:
return true
for dialog: Window in [
_cli_error_dialog,
_speech_recovery_dialog,
_speech_save_gate_dialog,
_scene_open_dialog,
_scene_save_dialog,
_unsaved_changes_dialog,
_rename_scene_dialog,
_missing_assets_dialog,
_missing_scenery_dialog,
_scenery_repair_confirm_dialog,
_group_preview_save_dialog,
_confirm_dialog,
]:
if dialog != null and is_instance_valid(dialog) and dialog.visible:
return true
return false
func _handle_cli_startup(args: Array) -> void: func _handle_cli_startup(args: Array) -> void:
if OS.get_environment("STICKMAN_WALK_DEBUG") == "1": if OS.get_environment("STICKMAN_WALK_DEBUG") == "1":
print("[WalkDebug] CLI_STARTUP args=%s" % [args]) print("[WalkDebug] CLI_STARTUP args=%s" % [args])
@@ -2806,7 +2955,7 @@ func _handle_cli_startup(args: Array) -> void:
return return
var scene_path := String(result.get("scene_path", "")) var scene_path := String(result.get("scene_path", ""))
if scene_path.is_empty(): if scene_path.is_empty():
_check_autosave_recovery() _check_autosave_recovery(true)
return return
if _document != null and _document.has_autosave(): if _document != null and _document.has_autosave():
_document.remove_autosave() _document.remove_autosave()
@@ -3085,6 +3234,9 @@ func _build_ui() -> void:
_asset_browser.asset_selected_requested.connect(_on_asset_selected) _asset_browser.asset_selected_requested.connect(_on_asset_selected)
_asset_browser.selector_cancel_requested.connect(_on_selector_cancelled) _asset_browser.selector_cancel_requested.connect(_on_selector_cancelled)
_asset_browser.plain_color_preview_requested.connect(_preview_plain_color)
_asset_browser.plain_color_commit_requested.connect(_commit_plain_color)
_asset_browser.plain_color_preview_cancel_requested.connect(_cancel_plain_color_preview)
_asset_browser.asset_load_failed.connect(func(kind: String, path: String) -> void: _asset_browser.asset_load_failed.connect(func(kind: String, path: String) -> void:
if _scenery_repair_target != null and is_instance_valid(_scenery_repair_target): if _scenery_repair_target != null and is_instance_valid(_scenery_repair_target):
_show_toast("Could not open that artwork. Try another file.") _show_toast("Could not open that artwork. Try another file.")
@@ -3097,6 +3249,7 @@ func _build_ui() -> void:
_asset_browser.edit_scenery_requested.connect(_enter_scenery_edit_mode) _asset_browser.edit_scenery_requested.connect(_enter_scenery_edit_mode)
_asset_browser.surface_color_confirmed.connect(_record_recent_surface_color) _asset_browser.surface_color_confirmed.connect(_record_recent_surface_color)
_asset_browser.set_surface_color_history(_recent_surface_colors) _asset_browser.set_surface_color_history(_recent_surface_colors)
_asset_browser.set_background_state(_background_kind, _sky_id, _plain_color)
_build_ground_finish_popup(ui) _build_ground_finish_popup(ui)
_modal_views.build_file_dialogs(ui) _modal_views.build_file_dialogs(ui)
@@ -4510,6 +4663,8 @@ func _build_gizmo_layer() -> void:
_gizmos = STAGE_GIZMOS.new() _gizmos = STAGE_GIZMOS.new()
_gizmos.name = "GizmoLayer" _gizmos.name = "GizmoLayer"
_gizmos.camera = _camera _gizmos.camera = _camera
if _sandbox_theme != null:
_gizmos.apply_theme(_sandbox_theme as SandboxTheme)
_gizmos.transform_committed.connect(_on_transform_committed) _gizmos.transform_committed.connect(_on_transform_committed)
_gizmos.transform_started.connect(_on_gizmo_transform_started) _gizmos.transform_started.connect(_on_gizmo_transform_started)
_gizmos.transform_updated.connect(_on_gizmo_transform_updated) _gizmos.transform_updated.connect(_on_gizmo_transform_updated)
@@ -4522,6 +4677,7 @@ func _build_grid_layer() -> void:
_grid.camera = _camera _grid.camera = _camera
add_child(_grid) add_child(_grid)
move_child(_grid, 0) move_child(_grid, 0)
_update_grid_background_style()
func _build_ghost_holder() -> void: func _build_ghost_holder() -> void:
@@ -4542,15 +4698,19 @@ func _build_scenery_controller() -> void:
func _build_sky_layer() -> void: func _build_sky_layer() -> void:
_sky_layer = CanvasLayer.new() _sky_layer = CanvasLayer.new()
_sky_layer.name = "StageSkyLayer" _sky_layer.name = "StageBackgroundLayer"
_sky_layer.layer = -1 _sky_layer.layer = -1
_sky_view = STAGE_SKY_VIEW_SCRIPT.new() as StageSkyView _background_view = STAGE_BACKGROUND_VIEW_SCRIPT.new() as StageBackgroundView
_sky_view.name = "StageSkyView" _background_view.name = "StageBackgroundView"
_sky_view.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) _background_view.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
_sky_view.set_sky(_sky_id) _background_view.set_background(_background_kind, _sky_id, _plain_color)
_sky_layer.add_child(_sky_view) _sky_layer.add_child(_background_view)
add_child(_sky_layer) add_child(_sky_layer)
_sky_view.bind_camera(_camera) _background_view.bind_camera(_camera)
_sky_view = _background_view.get_sky_view()
if _sandbox_theme != null:
_background_view.apply_theme(_sandbox_theme as SandboxTheme)
_update_grid_background_style()
func _build_placement_overlay() -> void: func _build_placement_overlay() -> void:
@@ -4912,7 +5072,13 @@ func _open_selector(kind: String) -> void:
(_palette_buttons[pid] as Button).set_pressed_no_signal(pid == kind) (_palette_buttons[pid] as Button).set_pressed_no_signal(pid == kind)
if kind == "scenery": if kind == "scenery":
_asset_browser.set_surface_color_history(_recent_surface_colors) _asset_browser.set_surface_color_history(_recent_surface_colors)
var selector_state: Dictionary = _asset_browser.open_selector(kind, _spawner.get_selected_stickman_path(), _sky_id) var selector_state: Dictionary = _asset_browser.open_selector(
kind,
_spawner.get_selected_stickman_path(),
_sky_id,
_background_kind,
_plain_color
)
if kind == "stickman": if kind == "stickman":
var selected_stickman_path: String = String(selector_state.get("selected_stickman_path", _spawner.get_selected_stickman_path())) var selected_stickman_path: String = String(selector_state.get("selected_stickman_path", _spawner.get_selected_stickman_path()))
if selected_stickman_path != _spawner.get_selected_stickman_path(): if selected_stickman_path != _spawner.get_selected_stickman_path():
@@ -4940,12 +5106,14 @@ func _on_asset_selected(entry: Dictionary) -> void:
return return
var background_kind: String = String(entry.get("background_kind", "")) var background_kind: String = String(entry.get("background_kind", ""))
if background_kind == "sky": if background_kind == "sky":
_sky_id = StringName(String(entry.get("id", "sky_neutral"))) _commit_background_kind(&"sky", StringName(String(entry.get("id", "sky_neutral"))))
_sky_view.set_sky(_sky_id) _refresh_scenery_capture_bar()
var scenery_selector: AssetSelector = _asset_browser.get_selector() return
if scenery_selector != null: if background_kind == "plain":
scenery_selector.set_current_sky(_sky_id) _commit_background_kind(&"plain")
_mark_scene_dirty() var plain_selector: AssetSelector = _asset_browser.get_selector()
if plain_selector != null:
plain_selector.open_plain_background_choices(_plain_color)
_refresh_scenery_capture_bar() _refresh_scenery_capture_bar()
return return
if background_kind == "wall": if background_kind == "wall":
@@ -5774,8 +5942,15 @@ func _handle_scenery_edit_motion(world_position: Vector2) -> void:
func _close_selector() -> void: func _close_selector() -> void:
var closing_kind: String = _selector_kind
_cancel_plain_color_preview()
if _asset_browser != null: if _asset_browser != null:
_asset_browser.close() _asset_browser.close()
if closing_kind == "scenery":
# Scenery is a chooser entry; the capture bar communicates active drawing tools.
var scenery_button: Button = _palette_buttons.get("scenery") as Button
if scenery_button != null:
scenery_button.set_pressed_no_signal(false)
func _on_selector_cancelled() -> void: func _on_selector_cancelled() -> void:
@@ -5783,7 +5958,7 @@ func _on_selector_cancelled() -> void:
return return
var kind: String = _selector_kind var kind: String = _selector_kind
_close_selector() _close_selector()
if kind != "scenery" and kind != "starters": if kind != "starters":
set_placement_mode("") set_placement_mode("")
@@ -7900,8 +8075,12 @@ func _load_font(path: String) -> Font:
return _theme_controller.load_font(path) return _theme_controller.load_font(path)
func _apply_theme_to_visuals() -> void: func _apply_theme_to_visuals() -> void:
if _sky_view != null and _sandbox_theme != null: if _background_view != null and _sandbox_theme != null:
_sky_view.apply_theme(_sandbox_theme as SandboxTheme) _background_view.apply_theme(_sandbox_theme as SandboxTheme)
if _grid != null:
_update_grid_background_style()
if _gizmos != null and _sandbox_theme != null:
_gizmos.apply_theme(_sandbox_theme as SandboxTheme)
if _director_visuals != null: if _director_visuals != null:
_director_visuals.set_style(_theme) _director_visuals.set_style(_theme)
_director_visuals.completed_path_alpha = _sandbox_theme.number("overlays.completed_path_alpha", 0.20, 0.0, 1.0) if _sandbox_theme != null else 0.20 _director_visuals.completed_path_alpha = _sandbox_theme.number("overlays.completed_path_alpha", 0.20, 0.0, 1.0) if _sandbox_theme != null else 0.20
+51 -5
View File
@@ -9,6 +9,9 @@ signal refresh_requested
signal make_artwork_requested signal make_artwork_requested
signal edit_scenery_requested signal edit_scenery_requested
signal surface_color_confirmed(color: Color) signal surface_color_confirmed(color: Color)
signal plain_color_preview_requested(color: Color)
signal plain_color_commit_requested(color: Color)
signal plain_color_preview_cancel_requested()
const ASSET_SELECTOR_SCENE := preload("res://scenes/stage/asset_selector.tscn") const ASSET_SELECTOR_SCENE := preload("res://scenes/stage/asset_selector.tscn")
const STICKMAN_LIBRARY_SCRIPT := preload("res://scripts/characters/stickman/stickman_library.gd") const STICKMAN_LIBRARY_SCRIPT := preload("res://scripts/characters/stickman/stickman_library.gd")
@@ -32,6 +35,9 @@ var browse_dialog: FileDialog
var thumbnail_queue: Array[Dictionary] = [] var thumbnail_queue: Array[Dictionary] = []
var thumbnail_busy: bool = false var thumbnail_busy: bool = false
var thumbnail_generation: int = 0 var thumbnail_generation: int = 0
var _current_background_kind: StringName = &"sky"
var _current_sky_id: StringName = &"sky_neutral"
var _current_plain_color: Color = Color("#F5EFE0")
func _ready() -> void: func _ready() -> void:
@@ -62,6 +68,10 @@ func build_ui(ui_layer: CanvasLayer, ui_font: Font, emoji_font: Font, sandbox_th
selector.make_artwork_requested.connect(func() -> void: make_artwork_requested.emit()) selector.make_artwork_requested.connect(func() -> void: make_artwork_requested.emit())
selector.edit_scenery_requested.connect(func() -> void: edit_scenery_requested.emit()) selector.edit_scenery_requested.connect(func() -> void: edit_scenery_requested.emit())
selector.surface_color_confirmed.connect(func(color: Color) -> void: surface_color_confirmed.emit(color)) selector.surface_color_confirmed.connect(func(color: Color) -> void: surface_color_confirmed.emit(color))
selector.plain_color_preview_requested.connect(func(color: Color) -> void: plain_color_preview_requested.emit(color))
selector.plain_color_commit_requested.connect(func(color: Color) -> void: plain_color_commit_requested.emit(color))
selector.plain_color_preview_cancel_requested.connect(func() -> void: plain_color_preview_cancel_requested.emit())
selector.stage_preview_dimming_changed.connect(_on_selector_stage_preview_dimming_changed)
ui_layer.add_child(selector) ui_layer.add_child(selector)
# apply_font AFTER add_child so the selector's @onready nodes resolve first. # apply_font AFTER add_child so the selector's @onready nodes resolve first.
selector.apply_font(ui_font, emoji_font) selector.apply_font(ui_font, emoji_font)
@@ -92,12 +102,28 @@ func set_surface_color_history(colors: Array[Color]) -> void:
selector.set_surface_color_history(colors) selector.set_surface_color_history(colors)
func set_background_state(kind: StringName, sky_id: StringName, plain_color: Color) -> void:
_current_background_kind = &"plain" if kind == &"plain" else &"sky"
_current_sky_id = sky_id
_current_plain_color = Color(plain_color.r, plain_color.g, plain_color.b, 1.0)
if selector != null:
selector.set_background_state(_current_background_kind, _current_sky_id, _current_plain_color)
func _starter_scene_entries() -> Array[Dictionary]: func _starter_scene_entries() -> Array[Dictionary]:
return [ return [
{
"id": "starter_plain_background",
"name": "Plain Background",
"description": "An empty stage with one color. Choose a new color whenever you like.",
"category": "Make your own",
"path": "res://content/stages/starters/plain_background.scene",
"icon": "🎨",
},
{ {
"id": "starter_blank_scene", "id": "starter_blank_scene",
"name": "Blank Scene", "name": "Open Sky",
"description": "Start fresh with an open stage and a clear sky.", "description": "An empty stage with a soft sky. Sun and clouds, ready for your story.",
"category": "Make your own", "category": "Make your own",
"path": "res://content/stages/starters/blank.scene", "path": "res://content/stages/starters/blank.scene",
"icon": "✨", "icon": "✨",
@@ -129,7 +155,16 @@ func make_browse_entry(kind: String, path: String) -> Dictionary:
return stickman_library.make_entry(path) return stickman_library.make_entry(path)
func open_selector(kind: String, current_stickman_path: String, current_sky_id: StringName = &"") -> Dictionary: func open_selector(
kind: String,
current_stickman_path: String,
current_sky_id: StringName = &"",
background_kind: StringName = &"sky",
plain_color: Color = Color("#F5EFE0")
) -> Dictionary:
_current_background_kind = &"plain" if background_kind == &"plain" else &"sky"
_current_sky_id = current_sky_id if not current_sky_id.is_empty() else &"sky_neutral"
_current_plain_color = Color(plain_color.r, plain_color.g, plain_color.b, 1.0)
set_selector_kind(kind) set_selector_kind(kind)
var entries: Array[Dictionary] = scan_entries(kind) var entries: Array[Dictionary] = scan_entries(kind)
if kind == "starters": if kind == "starters":
@@ -142,7 +177,7 @@ func open_selector(kind: String, current_stickman_path: String, current_sky_id:
selected_stickman_path = String(entries[0].get("path", "")) selected_stickman_path = String(entries[0].get("path", ""))
var auto_selection: Dictionary = entries[0] if kind == "stickman" and entries.size() == 1 else {} var auto_selection: Dictionary = entries[0] if kind == "stickman" and entries.size() == 1 else {}
if auto_selection.is_empty(): if auto_selection.is_empty():
open(kind, entries, current_sky_id) open(kind, entries, _current_sky_id)
return { return {
"entries": entries, "entries": entries,
"selected_stickman_path": selected_stickman_path, "selected_stickman_path": selected_stickman_path,
@@ -152,6 +187,7 @@ func open_selector(kind: String, current_stickman_path: String, current_sky_id:
func _scenery_background_entries() -> Array[Dictionary]: func _scenery_background_entries() -> Array[Dictionary]:
return [ return [
{"id": "plain_background", "name": "Plain Background", "category": "Scene background", "gallery_tab": "backgrounds", "background_kind": "plain", "plain_color": _current_plain_color, "icon": "🎨"},
{"id": "sky_clear_day", "name": "Clear Day", "category": "Sky", "gallery_tab": "backgrounds", "background_kind": "sky", "icon": "☀️"}, {"id": "sky_clear_day", "name": "Clear Day", "category": "Sky", "gallery_tab": "backgrounds", "background_kind": "sky", "icon": "☀️"},
{"id": "sky_cloudy_day", "name": "Cloudy Day", "category": "Sky", "gallery_tab": "backgrounds", "background_kind": "sky", "icon": "☁️"}, {"id": "sky_cloudy_day", "name": "Cloudy Day", "category": "Sky", "gallery_tab": "backgrounds", "background_kind": "sky", "icon": "☁️"},
{"id": "sky_sunset", "name": "Sunset", "category": "Sky", "gallery_tab": "backgrounds", "background_kind": "sky", "icon": "🌅"}, {"id": "sky_sunset", "name": "Sunset", "category": "Sky", "gallery_tab": "backgrounds", "background_kind": "sky", "icon": "🌅"},
@@ -170,8 +206,9 @@ func open(kind: String, entries: Array[Dictionary], current_sky_id: StringName =
selector_open = true selector_open = true
if selector_dim != null: if selector_dim != null:
selector_dim.visible = true selector_dim.visible = true
selector_dim.color = Color(0.0, 0.0, 0.0, SELECTOR_DIM_ALPHA)
if selector != null: if selector != null:
selector.open(kind, entries, String(current_sky_id)) selector.open(kind, entries, String(current_sky_id), String(_current_background_kind), _current_plain_color)
load_or_enqueue_thumbnails(kind, entries) load_or_enqueue_thumbnails(kind, entries)
@@ -206,6 +243,8 @@ func set_entries(entries: Array[Dictionary]) -> void:
func refresh_selector_entries() -> Array[Dictionary]: func refresh_selector_entries() -> Array[Dictionary]:
var entries: Array[Dictionary] = scan_entries(selector_kind) var entries: Array[Dictionary] = scan_entries(selector_kind)
if selector_kind == "scenery":
entries.append_array(_scenery_background_entries())
set_entries(entries) set_entries(entries)
return entries return entries
@@ -282,6 +321,13 @@ func _on_selector_cancelled() -> void:
selector_cancel_requested.emit() selector_cancel_requested.emit()
func _on_selector_stage_preview_dimming_changed(should_dim: bool) -> void:
if selector_dim == null:
return
selector_dim.color = Color(0.0, 0.0, 0.0, SELECTOR_DIM_ALPHA if should_dim else 0.0)
selector_dim.visible = selector_open
func _on_selector_popup_hide() -> void: func _on_selector_popup_hide() -> void:
if not selector_open: if not selector_open:
return return
@@ -130,6 +130,8 @@ func collect(
"version": STAGE_SCENE_IO.FILE_VERSION, "version": STAGE_SCENE_IO.FILE_VERSION,
"scene_name": scene_name, "scene_name": scene_name,
"sky_id": String(document_metadata.get("sky_id", "sky_neutral")), "sky_id": String(document_metadata.get("sky_id", "sky_neutral")),
"background_kind": String(document_metadata.get("background_kind", "sky")),
"plain_color": String(document_metadata.get("plain_color", STAGE_SCENE_IO.DEFAULT_PLAIN_COLOR)),
"camera": {"position": STAGE_SCENE_IO.vector_to_data(camera_position), "zoom": camera_zoom}, "camera": {"position": STAGE_SCENE_IO.vector_to_data(camera_position), "zoom": camera_zoom},
"objects": objects, "objects": objects,
"event_rules": rules_result["rules"], "event_rules": rules_result["rules"],
@@ -299,6 +301,8 @@ func apply(data: Dictionary, world: Node2D, spawner: StageSpawner) -> Dictionary
"missing_paths": missing_paths, "missing_paths": missing_paths,
"decoded_rules": decoded_rules, "decoded_rules": decoded_rules,
"sky_id": String(data.get("sky_id", "sky_neutral")), "sky_id": String(data.get("sky_id", "sky_neutral")),
"background_kind": String(data.get("background_kind", "sky")),
"plain_color": String(data.get("plain_color", STAGE_SCENE_IO.DEFAULT_PLAIN_COLOR)),
} }
@@ -39,14 +39,18 @@ func configure(selected: Color, recents: Array[Color], presets: Array[Color], st
func set_selected_no_signal(color: Color) -> void: func set_selected_no_signal(color: Color) -> void:
_selected = color _selected = color
_refresh_current_color() _refresh_current_color()
_recent_swatches.set_selected(color) if _recent_swatches != null:
_preset_swatches.set_selected(color) _recent_swatches.set_selected(color)
if _preset_swatches != null:
_preset_swatches.set_selected(color)
func set_recent_colors(colors: Array[Color]) -> void: func set_recent_colors(colors: Array[Color]) -> void:
if _recents == colors: if _recents == colors:
return return
_recents = colors.duplicate() _recents = colors.duplicate()
if _recent_empty_label == null or _recent_swatches == null:
return
_recent_empty_label.visible = _recents.is_empty() _recent_empty_label.visible = _recents.is_empty()
_recent_swatches.visible = not _recents.is_empty() _recent_swatches.visible = not _recents.is_empty()
_recent_swatches.configure(_recents, _selected, _stage_theme) _recent_swatches.configure(_recents, _selected, _stage_theme)
@@ -99,6 +103,7 @@ func _build_current_color_section(parent: Control) -> void:
current_row.add_theme_constant_override("separation", _compact_gap()) current_row.add_theme_constant_override("separation", _compact_gap())
parent.add_child(current_row) parent.add_child(current_row)
_current_chip = Button.new() _current_chip = Button.new()
_current_chip.name = "CurrentColorChip"
var swatch_size: float = float(_integer("stage_surface_colors.swatch_size", 48, 44, 96)) var swatch_size: float = float(_integer("stage_surface_colors.swatch_size", 48, 44, 96))
if _compact_mode: if _compact_mode:
swatch_size = maxf(swatch_size, 52.0) swatch_size = maxf(swatch_size, 52.0)
@@ -116,7 +121,8 @@ func _build_current_color_section(parent: Control) -> void:
func _build_recent_color_section(parent: Control) -> void: func _build_recent_color_section(parent: Control) -> void:
parent.add_child(_make_heading("Recently used")) parent.add_child(_make_heading("Recently used"))
_recent_empty_label = Label.new() _recent_empty_label = Label.new()
_recent_empty_label.text = "No colors yet" if _compact_mode else "Colors you use will appear here" _recent_empty_label.name = "RecentColorsEmptyLabel"
_recent_empty_label.text = "No colors yet" if _compact_mode else "Colors you use will appear here."
_recent_empty_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART _recent_empty_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
_recent_empty_label.add_theme_color_override("font_color", _color("global.muted_text_color", Color("#AAB2C0"))) _recent_empty_label.add_theme_color_override("font_color", _color("global.muted_text_color", Color("#AAB2C0")))
if _compact_mode: if _compact_mode:
@@ -125,7 +131,7 @@ func _build_recent_color_section(parent: Control) -> void:
_recent_swatches = COLOR_SWATCH_SELECTOR.new() as ColorSwatchSelector _recent_swatches = COLOR_SWATCH_SELECTOR.new() as ColorSwatchSelector
_recent_swatches.size_flags_horizontal = Control.SIZE_EXPAND_FILL _recent_swatches.size_flags_horizontal = Control.SIZE_EXPAND_FILL
if _compact_mode: if _compact_mode:
_recent_swatches.set_swatch_layout_override(_integer("popups.asset_selector.compact_swatch_size", 42, 28, 52), 8) _recent_swatches.set_swatch_layout_override(_integer("popups.asset_selector.compact_swatch_size", 44, 44, 52), 8)
_recent_swatches.color_selected.connect(_on_swatch_selected) _recent_swatches.color_selected.connect(_on_swatch_selected)
parent.add_child(_recent_swatches) parent.add_child(_recent_swatches)
@@ -135,7 +141,7 @@ func _build_palette_section(parent: Control) -> void:
_preset_swatches = COLOR_SWATCH_SELECTOR.new() as ColorSwatchSelector _preset_swatches = COLOR_SWATCH_SELECTOR.new() as ColorSwatchSelector
_preset_swatches.size_flags_horizontal = Control.SIZE_EXPAND_FILL _preset_swatches.size_flags_horizontal = Control.SIZE_EXPAND_FILL
if _compact_mode: if _compact_mode:
_preset_swatches.set_swatch_layout_override(_integer("popups.asset_selector.compact_swatch_size", 42, 28, 52), 8) _preset_swatches.set_swatch_layout_override(_integer("popups.asset_selector.compact_swatch_size", 44, 44, 52), 8)
_preset_swatches.color_selected.connect(_on_swatch_selected) _preset_swatches.color_selected.connect(_on_swatch_selected)
parent.add_child(_preset_swatches) parent.add_child(_preset_swatches)
@@ -22,9 +22,11 @@ var _preferred_preview_height: float = 140.0
var _preferred_picker_min_size: Vector2 = Vector2(320.0, 340.0) var _preferred_picker_min_size: Vector2 = Vector2(320.0, 340.0)
var _built: bool = false var _built: bool = false
var _suppress_color_signal: bool = false var _suppress_color_signal: bool = false
var _plain_background_mode: bool = false
func configure(surface_kind: StringName, finish: StringName, color: Color, stage_theme: SandboxTheme) -> void: func configure(surface_kind: StringName, finish: StringName, color: Color, stage_theme: SandboxTheme) -> void:
_plain_background_mode = false
_surface_kind = surface_kind _surface_kind = surface_kind
_finish_id = finish _finish_id = finish
_stage_theme = stage_theme _stage_theme = stage_theme
@@ -35,6 +37,19 @@ func configure(surface_kind: StringName, finish: StringName, color: Color, stage
_apply_preview_heading_theme() _apply_preview_heading_theme()
func configure_plain_background(color: Color, stage_theme: SandboxTheme) -> void:
_plain_background_mode = true
_surface_kind = &"plain_background"
_finish_id = &""
_stage_theme = stage_theme
if not _built:
_build()
set_color_no_signal(Color(color.r, color.g, color.b, 1.0))
_color_picker.edit_alpha = false
theme = stage_theme.control_theme() if stage_theme != null else null
_apply_preview_heading_theme()
func get_color() -> Color: func get_color() -> Color:
return _color_picker.color if _color_picker != null else Color.WHITE return _color_picker.color if _color_picker != null else Color.WHITE
+53 -3
View File
@@ -15,6 +15,26 @@ var _label: Label = null
var _description: Label = null var _description: Label = null
var _status_label: Label = null var _status_label: Label = null
static var _rounded_preview_shader: Shader
const ROUNDED_PREVIEW_SHADER_CODE := """
shader_type canvas_item;
uniform float corner_radius_px = 12.0;
void fragment() {
vec4 preview_color = texture(TEXTURE, UV);
vec2 preview_size = vec2(1.0) / TEXTURE_PIXEL_SIZE;
vec2 half_size = preview_size * 0.5;
vec2 local_position = UV * preview_size;
vec2 rounded_box = abs(local_position - half_size) - (half_size - vec2(corner_radius_px));
float edge_distance = length(max(rounded_box, vec2(0.0))) + min(max(rounded_box.x, rounded_box.y), 0.0) - corner_radius_px;
float antialias_width = max(fwidth(edge_distance), 1.0);
preview_color.a *= 1.0 - smoothstep(0.0, antialias_width, edge_distance);
COLOR = preview_color;
}
"""
func configure(payload: Dictionary, icon_texture: Texture2D = null, theme: Variant = null) -> void: func configure(payload: Dictionary, icon_texture: Texture2D = null, theme: Variant = null) -> void:
_payload = payload.duplicate(true) _payload = payload.duplicate(true)
_drag_threshold = theme.number("palette.drag_threshold", 8.0, 1.0, 128.0) if theme != null else 8.0 _drag_threshold = theme.number("palette.drag_threshold", 8.0, 1.0, 128.0) if theme != null else 8.0
@@ -32,7 +52,9 @@ func configure(payload: Dictionary, icon_texture: Texture2D = null, theme: Varia
_box.alignment = BoxContainer.ALIGNMENT_CENTER; _box.add_theme_constant_override("separation", 2); add_child(_box) _box.alignment = BoxContainer.ALIGNMENT_CENTER; _box.add_theme_constant_override("separation", 2); add_child(_box)
_icon = TextureRect.new(); _icon.custom_minimum_size = thumbnail_size; _icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE; _icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED; _icon.texture = icon_texture; _icon.visible = icon_texture != null; _icon.mouse_filter = Control.MOUSE_FILTER_IGNORE; _box.add_child(_icon) _icon = TextureRect.new(); _icon.custom_minimum_size = thumbnail_size; _icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE; _icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED; _icon.texture = icon_texture; _icon.visible = icon_texture != null; _icon.mouse_filter = Control.MOUSE_FILTER_IGNORE; _box.add_child(_icon)
_glyph = Label.new(); _glyph.text = String(_payload.get("icon", "")); _glyph.visible = icon_texture == null; _glyph.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER; _glyph.mouse_filter = Control.MOUSE_FILTER_IGNORE; _glyph.add_theme_font_size_override("font_size", 30); _box.add_child(_glyph) _glyph = Label.new(); _glyph.text = String(_payload.get("icon", "")); _glyph.visible = icon_texture == null; _glyph.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER; _glyph.mouse_filter = Control.MOUSE_FILTER_IGNORE; _glyph.add_theme_font_size_override("font_size", 30); _box.add_child(_glyph)
_label = Label.new(); _label.text = String(_payload.get("label", "")); _label.custom_minimum_size = Vector2(0, 28); _label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER; _label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART; _label.clip_text = true; _label.mouse_filter = Control.MOUSE_FILTER_IGNORE; _box.add_child(_label) _label = Label.new(); _label.text = String(_payload.get("label", "")); _label.custom_minimum_size = Vector2(0, float(_payload.get("label_min_height", 28.0))); _label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER; _label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART; _label.clip_text = true; _label.mouse_filter = Control.MOUSE_FILTER_IGNORE; _box.add_child(_label)
if _payload.has("label_font_size"):
_label.add_theme_font_size_override("font_size", int(_payload["label_font_size"]))
var description: String = String(_payload.get("description", "")) var description: String = String(_payload.get("description", ""))
var status: String = String(_payload.get("status", "")) var status: String = String(_payload.get("status", ""))
if not status.is_empty(): if not status.is_empty():
@@ -56,6 +78,8 @@ func configure(payload: Dictionary, icon_texture: Texture2D = null, theme: Varia
_description.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART _description.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
_description.max_lines_visible = 2 _description.max_lines_visible = 2
_description.add_theme_font_size_override("font_size", 14) _description.add_theme_font_size_override("font_size", 14)
if _payload.has("description_font_size"):
_description.add_theme_font_size_override("font_size", int(_payload["description_font_size"]))
_description.mouse_filter = Control.MOUSE_FILTER_IGNORE _description.mouse_filter = Control.MOUSE_FILTER_IGNORE
_box.add_child(_description) _box.add_child(_description)
@@ -75,8 +99,34 @@ func set_preview_control(preview: Control) -> void:
preview.custom_minimum_size = preview_size preview.custom_minimum_size = preview_size
preview.size_flags_horizontal = Control.SIZE_EXPAND_FILL preview.size_flags_horizontal = Control.SIZE_EXPAND_FILL
preview.mouse_filter = Control.MOUSE_FILTER_IGNORE preview.mouse_filter = Control.MOUSE_FILTER_IGNORE
_box.add_child(preview) var preview_corner_radius: float = float(_payload.get("preview_corner_radius", 0.0))
_box.move_child(preview, 0) if preview_corner_radius > 0.0:
var rounded_material := ShaderMaterial.new()
rounded_material.shader = _get_rounded_preview_shader()
rounded_material.set_shader_parameter("corner_radius_px", preview_corner_radius)
preview.material = rounded_material
var horizontal_inset: int = int(_payload.get("preview_horizontal_inset", 0))
var top_inset: int = int(_payload.get("preview_top_inset", 0))
if horizontal_inset > 0 or top_inset > 0:
var preview_frame := MarginContainer.new()
preview_frame.name = "PreviewInsetFrame"
preview_frame.size_flags_horizontal = Control.SIZE_EXPAND_FILL
preview_frame.add_theme_constant_override("margin_left", horizontal_inset)
preview_frame.add_theme_constant_override("margin_right", horizontal_inset)
preview_frame.add_theme_constant_override("margin_top", top_inset)
preview_frame.add_child(preview)
_box.add_child(preview_frame)
_box.move_child(preview_frame, 0)
else:
_box.add_child(preview)
_box.move_child(preview, 0)
func _get_rounded_preview_shader() -> Shader:
if _rounded_preview_shader == null:
_rounded_preview_shader = Shader.new()
_rounded_preview_shader.code = ROUNDED_PREVIEW_SHADER_CODE
return _rounded_preview_shader
func set_thumbnail(texture: Texture2D) -> void: func set_thumbnail(texture: Texture2D) -> void:
if _icon != null: _icon.texture = texture; _icon.visible = texture != null if _icon != null: _icon.texture = texture; _icon.visible = texture != null
+467 -64
View File
@@ -8,6 +8,10 @@ signal refresh_requested()
signal make_artwork_requested() signal make_artwork_requested()
signal edit_scenery_requested() signal edit_scenery_requested()
signal surface_color_confirmed(color: Color) signal surface_color_confirmed(color: Color)
signal plain_color_preview_requested(color: Color)
signal plain_color_commit_requested(color: Color)
signal plain_color_preview_cancel_requested()
signal stage_preview_dimming_changed(should_dim: bool)
const COLUMNS := 4 const COLUMNS := 4
const ROWS := 3 const ROWS := 3
@@ -49,11 +53,14 @@ var _filter_chip_group: ButtonGroup
var _artwork_filter_buttons: Array[Button] = [] var _artwork_filter_buttons: Array[Button] = []
var _tag_id: String = "all" var _tag_id: String = "all"
var _current_sky_id: String = "" var _current_sky_id: String = ""
var _current_background_kind: StringName = &"sky"
var _current_plain_color: Color = Color("#F5EFE0")
var _sky_card_group: ButtonGroup var _sky_card_group: ButtonGroup
var _active_columns: int = COLUMNS var _active_columns: int = COLUMNS
var _page_capacity: int = PAGE_SIZE var _page_capacity: int = PAGE_SIZE
var _effective_cell_size: Vector2 = CELL_MIN_SIZE var _effective_cell_size: Vector2 = CELL_MIN_SIZE
var _surface_cell_size: Vector2 = CELL_MIN_SIZE var _surface_cell_size: Vector2 = CELL_MIN_SIZE
var _surface_row_heading: Label
var _surface_color_history: Array[Color] = [] var _surface_color_history: Array[Color] = []
var _setup_view: VBoxContainer var _setup_view: VBoxContainer
var _color_picker_view: StageSurfaceColorPickerView var _color_picker_view: StageSurfaceColorPickerView
@@ -69,6 +76,18 @@ var _setup_cancel_button: Button
var _setup_draw_button: Button var _setup_draw_button: Button
var _color_back_button: Button var _color_back_button: Button
var _color_use_button: Button var _color_use_button: Button
var _plain_color_view: VBoxContainer
var _plain_color_preview: StageSurfacePreview
var _plain_color_controls: StageSurfaceColorControls
var _plain_color_helper: Label
var _plain_color_choices_open: bool = false
var _plain_color_original: Color = Color("#F5EFE0")
var _plain_color_draft: Color = Color("#F5EFE0")
var _color_picker_owner: StringName = &"surface"
var _backgrounds_back_button: Button
var _plain_footer_row: HBoxContainer
var _plain_footer_column: VBoxContainer
var _stage_preview_is_dimmed: bool = true
@onready var _title_label: Label = %TitleLabel @onready var _title_label: Label = %TitleLabel
@onready var _grid: GridContainer = %GridContainer @onready var _grid: GridContainer = %GridContainer
@@ -103,6 +122,8 @@ func _ready() -> void:
tab.toggle_mode = true tab.toggle_mode = true
tab.button_group = _gallery_tab_group tab.button_group = _gallery_tab_group
_build_surface_setup_view() _build_surface_setup_view()
_build_plain_background_view()
_build_surface_row_heading()
_rebuild_artwork_filter_chips() _rebuild_artwork_filter_chips()
_prev_button.pressed.connect(_on_prev) _prev_button.pressed.connect(_on_prev)
_next_button.pressed.connect(_on_next) _next_button.pressed.connect(_on_next)
@@ -113,6 +134,7 @@ func _ready() -> void:
_artwork_tab.pressed.connect(func() -> void: _set_gallery_tab("artwork")) _artwork_tab.pressed.connect(func() -> void: _set_gallery_tab("artwork"))
_make_artwork_button.pressed.connect(func() -> void: make_artwork_requested.emit()) _make_artwork_button.pressed.connect(func() -> void: make_artwork_requested.emit())
_edit_scenery_button.pressed.connect(func() -> void: edit_scenery_requested.emit()) _edit_scenery_button.pressed.connect(func() -> void: edit_scenery_requested.emit())
popup_hide.connect(_on_popup_hide)
get_tree().root.size_changed.connect(_on_root_size_changed) get_tree().root.size_changed.connect(_on_root_size_changed)
_apply_chooser_visual_style() _apply_chooser_visual_style()
@@ -123,15 +145,27 @@ func _on_root_size_changed() -> void:
_rebuild() _rebuild()
func open(p_kind: String, entries: Array[Dictionary], current_sky_id: String = "") -> void: func open(
p_kind: String,
entries: Array[Dictionary],
current_sky_id: String = "",
current_background_kind: String = "sky",
plain_color: Color = Color("#F5EFE0")
) -> void:
_cancel_plain_picker_preview(false)
kind = p_kind kind = p_kind
_setup_kind = &"" _setup_kind = &""
_color_picker_open = false _color_picker_open = false
_plain_color_choices_open = false
_setup_view.visible = false _setup_view.visible = false
_plain_color_view.visible = false
if _color_picker_view != null: if _color_picker_view != null:
_color_picker_view.visible = false _color_picker_view.visible = false
_current_sky_id = current_sky_id if kind == "scenery" else "" _current_sky_id = current_sky_id if kind == "scenery" else ""
_current_background_kind = &"plain" if current_background_kind == "plain" else &"sky"
_current_plain_color = _opaque_color(plain_color)
_title_label.text = "Choose Your Stickman" if kind == "stickman" else ("Choose Scenery" if kind == "scenery" else ("Choose a starter scene" if kind == "starters" else "Choose a Prop")) _title_label.text = "Choose Your Stickman" if kind == "stickman" else ("Choose Scenery" if kind == "scenery" else ("Choose a starter scene" if kind == "starters" else "Choose a Prop"))
_backgrounds_back_button.visible = false
_apply_chooser_visual_style() _apply_chooser_visual_style()
_tabs.visible = kind == "scenery" _tabs.visible = kind == "scenery"
_filter_chips.visible = false _filter_chips.visible = false
@@ -165,6 +199,47 @@ func set_surface_color_history(colors: Array[Color]) -> void:
_surface_color_history = colors.duplicate() _surface_color_history = colors.duplicate()
if _setup_color_controls != null and is_instance_valid(_setup_color_controls): if _setup_color_controls != null and is_instance_valid(_setup_color_controls):
_setup_color_controls.set_recent_colors(_surface_color_history) _setup_color_controls.set_recent_colors(_surface_color_history)
if _plain_color_controls != null and is_instance_valid(_plain_color_controls):
_plain_color_controls.set_recent_colors(_surface_color_history)
func set_background_state(background_kind: StringName, sky_id: StringName, plain_color: Color) -> void:
_current_background_kind = &"plain" if background_kind == &"plain" else &"sky"
_current_sky_id = String(sky_id)
_current_plain_color = _opaque_color(plain_color)
for entry: Dictionary in _entries:
if String(entry.get("background_kind", "")) == "plain":
entry["plain_color"] = _current_plain_color
if not _plain_color_choices_open and not (_color_picker_open and _color_picker_owner == &"plain"):
_plain_color_draft = _current_plain_color
if _plain_color_preview != null:
_plain_color_preview.configure(&"plain_background", &"", _current_plain_color)
if _plain_color_controls != null:
_plain_color_controls.set_selected_no_signal(_current_plain_color)
if _color_picker_open and _color_picker_owner == &"plain" and _color_picker_view != null:
_color_picker_view.configure_plain_background(_current_plain_color, _sandbox_theme as SandboxTheme)
if kind == "scenery" and _gallery_tab == "backgrounds":
_rebuild()
func open_plain_background_choices(color: Color) -> void:
_current_plain_color = _opaque_color(color)
_plain_color_draft = _current_plain_color
_plain_color_choices_open = true
_color_picker_open = false
_color_picker_owner = &"plain"
_title_label.text = "Choose background color"
_backgrounds_back_button.text = "‹ Backgrounds"
_backgrounds_back_button.visible = true
_plain_color_view.visible = true
_setup_view.visible = false
_color_picker_view.visible = false
_plain_color_preview.configure(&"plain_background", &"", _current_plain_color)
_plain_color_controls.configure(_current_plain_color, _surface_color_history, _preset_surface_colors(), _sandbox_theme as SandboxTheme)
_update_popup_layout(true)
_rebuild()
call_deferred("_update_popup_layout_after_layout")
call_deferred("_focus_plain_color_controls")
func set_thumbnail(entry: Dictionary, tex: Texture2D) -> void: func set_thumbnail(entry: Dictionary, tex: Texture2D) -> void:
@@ -198,6 +273,7 @@ func apply_font(ui_font: Font, emoji_font: Font) -> void:
_prev_button, _next_button, _browse_button, _refresh_button, _close_button, _prev_button, _next_button, _browse_button, _refresh_button, _close_button,
_edit_scenery_button, _make_artwork_button, _edit_scenery_button, _make_artwork_button,
_backgrounds_tab, _artwork_tab, _backgrounds_tab, _artwork_tab,
_backgrounds_back_button, _plain_color_helper,
_setup_view.get_node_or_null("SetupHeading") if _setup_view != null else null, _setup_view.get_node_or_null("SetupHeading") if _setup_view != null else null,
get_meta("setup_helper", null) as Control, get_meta("setup_helper", null) as Control,
_setup_cancel_button, _setup_draw_button, _setup_cancel_button, _setup_draw_button,
@@ -226,8 +302,13 @@ func apply_theme(theme: Variant) -> void:
ground_choices.apply_theme(theme as SandboxTheme) ground_choices.apply_theme(theme as SandboxTheme)
if _setup_color_controls != null: if _setup_color_controls != null:
_setup_color_controls.configure(_setup_color, _surface_color_history, _preset_surface_colors(), theme as SandboxTheme) _setup_color_controls.configure(_setup_color, _surface_color_history, _preset_surface_colors(), theme as SandboxTheme)
if _plain_color_controls != null:
_plain_color_controls.configure(_current_plain_color, _surface_color_history, _preset_surface_colors(), theme as SandboxTheme)
if _color_picker_view != null: if _color_picker_view != null:
_color_picker_view.configure(_setup_kind, _setup_finish, _setup_color, theme as SandboxTheme) if _color_picker_owner == &"plain":
_color_picker_view.configure_plain_background(_plain_color_draft, theme as SandboxTheme)
else:
_color_picker_view.configure(_setup_kind, _setup_finish, _setup_color, theme as SandboxTheme)
_apply_chooser_visual_style() _apply_chooser_visual_style()
@@ -305,7 +386,7 @@ func _build_surface_setup_view() -> void:
_color_picker_view = SURFACE_COLOR_PICKER_VIEW.new() as StageSurfaceColorPickerView _color_picker_view = SURFACE_COLOR_PICKER_VIEW.new() as StageSurfaceColorPickerView
_color_picker_view.name = "SurfaceColorPickerView" _color_picker_view.name = "SurfaceColorPickerView"
_color_picker_view.size_flags_horizontal = Control.SIZE_EXPAND_FILL _color_picker_view.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_color_picker_view.preview_color_changed.connect(_on_setup_color_preview) _color_picker_view.preview_color_changed.connect(_on_color_picker_preview)
_color_picker_view.visible = false _color_picker_view.visible = false
_content_stack.add_child(_color_picker_view) _content_stack.add_child(_color_picker_view)
_setup_cancel_button = Button.new() _setup_cancel_button = Button.new()
@@ -349,6 +430,77 @@ func _build_surface_setup_view() -> void:
_apply_font_to(choice) _apply_font_to(choice)
func _build_plain_background_view() -> void:
_plain_color_view = VBoxContainer.new()
_plain_color_view.name = "PlainBackgroundColorChoices"
_plain_color_view.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_plain_color_view.add_theme_constant_override("separation", _theme_integer("popups.asset_selector.setup_gap", 8, 4, 24))
_plain_color_view.visible = false
_content_stack.add_child(_plain_color_view)
_plain_color_helper = Label.new()
_plain_color_helper.name = "PlainBackgroundHelper"
_plain_color_helper.text = "Tap a color to use it on the Stage."
_plain_color_helper.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
_plain_color_helper.add_theme_color_override("font_color", _theme_color("global.muted_text_color", Color("#AAB2C0")))
_plain_color_view.add_child(_plain_color_helper)
var preview_frame := PanelContainer.new()
preview_frame.name = "PlainBackgroundPreviewFrame"
var preview_size: Vector2 = _theme_vector2("popups.asset_selector.surface_preview_size", Vector2(420.0, 132.0))
preview_size.y = minf(preview_size.y, 132.0)
preview_frame.custom_minimum_size.y = preview_size.y + 6.0
preview_frame.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_plain_color_preview = SURFACE_PREVIEW.new() as StageSurfacePreview
_plain_color_preview.name = "PlainBackgroundPreview"
_plain_color_preview.set_rounded_frame(
float(_theme_integer("popups.asset_selector.surface_corner_radius", 14, 4, 32)),
_theme_color("popups.style_defaults.bg_color", Color("#202633FA"))
)
_plain_color_preview.custom_minimum_size = preview_size
_plain_color_preview.size_flags_horizontal = Control.SIZE_EXPAND_FILL
preview_frame.add_child(_plain_color_preview)
_plain_color_view.add_child(preview_frame)
_plain_color_controls = SURFACE_COLOR_CONTROLS.new() as StageSurfaceColorControls
_plain_color_controls.name = "PlainBackgroundColorControls"
_plain_color_controls.color_selected.connect(_on_plain_color_selected)
_plain_color_controls.custom_color_requested.connect(_open_plain_color_picker)
_plain_color_view.add_child(_plain_color_controls)
_backgrounds_back_button = Button.new()
_backgrounds_back_button.name = "BackgroundsBackButton"
_backgrounds_back_button.text = "‹ Backgrounds"
_backgrounds_back_button.custom_minimum_size = Vector2(148.0, float(_theme_integer("stage_panels.action.min_target_size", 48, 44, 96)))
_backgrounds_back_button.focus_mode = Control.FOCUS_ALL
_backgrounds_back_button.visible = false
_backgrounds_back_button.pressed.connect(_back_to_backgrounds)
_footer.add_child(_backgrounds_back_button)
_plain_footer_row = HBoxContainer.new()
_plain_footer_row.name = "PlainBackgroundFooterRow"
_plain_footer_row.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_plain_footer_row.alignment = BoxContainer.ALIGNMENT_BEGIN
_plain_footer_row.add_theme_constant_override("separation", _theme_integer("popups.asset_selector.footer_gap", 16, 8, 32))
_plain_footer_row.visible = false
_footer.add_child(_plain_footer_row)
_plain_footer_column = VBoxContainer.new()
_plain_footer_column.name = "PlainBackgroundFooterColumn"
_plain_footer_column.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_plain_footer_column.add_theme_constant_override("separation", _theme_integer("popups.asset_selector.footer_gap", 16, 8, 32))
_plain_footer_column.visible = false
_footer.add_child(_plain_footer_column)
_apply_font_to(_plain_color_helper)
_apply_font_to(_backgrounds_back_button)
_apply_chooser_visual_style()
func _build_surface_row_heading() -> void:
_surface_row_heading = Label.new()
_surface_row_heading.name = "MoreBackgroundsHeading"
_surface_row_heading.text = "More backgrounds"
_surface_row_heading.visible = false
_surface_row_heading.add_theme_font_size_override("font_size", _theme_integer("popups.asset_selector.setup_heading_size", 26, 18, 48))
_content_stack.add_child(_surface_row_heading)
_content_stack.move_child(_surface_row_heading, _surface_cards_row.get_index())
_apply_font_to(_surface_row_heading)
func _make_look_cue(kind: StringName, finish: StringName) -> Control: func _make_look_cue(kind: StringName, finish: StringName) -> Control:
var preview: StageSurfacePreview = SURFACE_PREVIEW.new() as StageSurfacePreview var preview: StageSurfacePreview = SURFACE_PREVIEW.new() as StageSurfacePreview
var cue_size: Vector2 = _theme_vector2("popups.asset_selector.look_cue_size", Vector2(80.0, 42.0)) var cue_size: Vector2 = _theme_vector2("popups.asset_selector.look_cue_size", Vector2(80.0, 42.0))
@@ -418,6 +570,14 @@ func _on_setup_color_selected(color: Color) -> void:
surface_color_confirmed.emit(_setup_color) surface_color_confirmed.emit(_setup_color)
func _on_plain_color_selected(color: Color) -> void:
_current_plain_color = _opaque_color(color)
_plain_color_draft = _current_plain_color
_plain_color_preview.configure(&"plain_background", &"", _current_plain_color)
_plain_color_controls.set_selected_no_signal(_current_plain_color)
plain_color_commit_requested.emit(_current_plain_color)
func _update_setup_preview() -> void: func _update_setup_preview() -> void:
if _setup_preview == null: if _setup_preview == null:
return return
@@ -437,6 +597,7 @@ func _open_setup_color_view() -> void:
_setup_original_color = _setup_color _setup_original_color = _setup_color
_color_picker_view.configure(_setup_kind, _setup_finish, _setup_original_color, _sandbox_theme as SandboxTheme) _color_picker_view.configure(_setup_kind, _setup_finish, _setup_original_color, _sandbox_theme as SandboxTheme)
_color_picker_open = true _color_picker_open = true
_color_picker_owner = &"surface"
_title_label.text = "Choose color" _title_label.text = "Choose color"
_rebuild() _rebuild()
_update_popup_layout() _update_popup_layout()
@@ -444,12 +605,45 @@ func _open_setup_color_view() -> void:
_color_picker_view.focus_picker() _color_picker_view.focus_picker()
func _open_plain_color_picker() -> void:
if not _plain_color_choices_open:
return
_plain_color_original = _current_plain_color
_plain_color_draft = _current_plain_color
_color_picker_owner = &"plain"
_color_picker_view.configure_plain_background(_plain_color_draft, _sandbox_theme as SandboxTheme)
_color_back_button.text = "‹ Plain Background"
_plain_color_choices_open = false
_color_picker_open = true
_title_label.text = "Choose background color"
_backgrounds_back_button.visible = false
_update_popup_layout(true)
_rebuild()
call_deferred("_update_popup_layout_after_layout")
_color_picker_view.focus_picker()
func _on_setup_color_preview(color: Color) -> void: func _on_setup_color_preview(color: Color) -> void:
_setup_color = _opaque_color(color) _setup_color = _opaque_color(color)
_update_setup_preview() _update_setup_preview()
func _on_color_picker_preview(color: Color) -> void:
if _color_picker_owner == &"plain":
_plain_color_draft = _opaque_color(color)
plain_color_preview_requested.emit(_plain_color_draft)
return
_on_setup_color_preview(color)
func _use_setup_color() -> void: func _use_setup_color() -> void:
if _color_picker_owner == &"plain":
_current_plain_color = _opaque_color(_color_picker_view.get_color())
_plain_color_draft = _current_plain_color
_plain_color_preview.configure(&"plain_background", &"", _current_plain_color)
plain_color_commit_requested.emit(_current_plain_color)
_close_plain_color_picker()
return
_setup_color = _opaque_color(_color_picker_view.get_color()) _setup_color = _opaque_color(_color_picker_view.get_color())
_setup_color_chosen = true _setup_color_chosen = true
_update_setup_preview() _update_setup_preview()
@@ -459,6 +653,9 @@ func _use_setup_color() -> void:
func _back_from_setup_color_view() -> void: func _back_from_setup_color_view() -> void:
if _color_picker_owner == &"plain":
_cancel_plain_picker_preview(true)
return
_setup_color = _setup_original_color _setup_color = _setup_original_color
_setup_color_controls.set_selected_no_signal(_setup_color) _setup_color_controls.set_selected_no_signal(_setup_color)
_update_setup_preview() _update_setup_preview()
@@ -475,6 +672,74 @@ func _close_setup_color_view() -> void:
call_deferred("_update_popup_layout_after_layout") call_deferred("_update_popup_layout_after_layout")
func _close_plain_color_picker() -> void:
_color_picker_open = false
_plain_color_choices_open = true
_title_label.text = "Choose background color"
_backgrounds_back_button.text = "‹ Backgrounds"
_backgrounds_back_button.visible = true
_plain_color_view.visible = true
_plain_color_preview.configure(&"plain_background", &"", _current_plain_color)
_plain_color_controls.set_selected_no_signal(_current_plain_color)
_update_popup_layout(true)
_rebuild()
call_deferred("_update_popup_layout_after_layout")
call_deferred("_focus_plain_color_controls")
func _cancel_plain_picker_preview(return_to_choices: bool = true) -> void:
if not _color_picker_open or _color_picker_owner != &"plain":
return
_plain_color_draft = _current_plain_color
_color_picker_open = false
plain_color_preview_cancel_requested.emit()
if _color_picker_view != null:
_color_picker_view.configure_plain_background(_current_plain_color, _sandbox_theme as SandboxTheme)
if return_to_choices and kind == "scenery":
_plain_color_choices_open = true
_title_label.text = "Choose background color"
_backgrounds_back_button.text = "‹ Backgrounds"
_backgrounds_back_button.visible = true
_plain_color_view.visible = true
_plain_color_preview.configure(&"plain_background", &"", _current_plain_color)
_plain_color_controls.set_selected_no_signal(_current_plain_color)
_update_popup_layout(true)
_rebuild()
call_deferred("_update_popup_layout_after_layout")
call_deferred("_focus_plain_color_controls")
func _back_to_backgrounds() -> void:
if _color_picker_open and _color_picker_owner == &"plain":
_cancel_plain_picker_preview(true)
return
_plain_color_choices_open = false
_plain_color_view.visible = false
_backgrounds_back_button.visible = false
_title_label.text = "Choose the scene background"
_update_popup_layout(true)
_rebuild()
call_deferred("_focus_plain_background_card")
func _focus_plain_color_controls() -> void:
if _plain_color_controls != null and _plain_color_controls.visible:
_plain_color_controls.focus_custom_button()
func _focus_plain_background_card() -> void:
for node: Node in _grid.get_children():
var card: AssetCard = node as AssetCard
if card != null and String(card.get_meta("entry_id", "")) == "plain_background":
card.grab_focus()
return
func _on_popup_hide() -> void:
if _color_picker_open and _color_picker_owner == &"plain":
_cancel_plain_picker_preview(true)
func _opaque_color(color: Color) -> Color: func _opaque_color(color: Color) -> Color:
return Color(color.r, color.g, color.b, 1.0) return Color(color.r, color.g, color.b, 1.0)
@@ -600,11 +865,17 @@ func _has_unsorted_artwork() -> bool:
func _set_gallery_tab(tab: String) -> void: func _set_gallery_tab(tab: String) -> void:
if _color_picker_open and _color_picker_owner == &"plain":
_cancel_plain_picker_preview(false)
_color_picker_open = false _color_picker_open = false
_plain_color_choices_open = false
_setup_kind = &"" _setup_kind = &""
_setup_view.visible = false _setup_view.visible = false
_plain_color_view.visible = false
_color_picker_view.visible = false _color_picker_view.visible = false
_backgrounds_back_button.visible = false
_gallery_tab = tab _gallery_tab = tab
_title_label.text = "Choose the scene background" if tab == "backgrounds" else "Choose Scenery"
_backgrounds_tab.set_pressed_no_signal(tab == "backgrounds") _backgrounds_tab.set_pressed_no_signal(tab == "backgrounds")
_artwork_tab.set_pressed_no_signal(tab == "artwork") _artwork_tab.set_pressed_no_signal(tab == "artwork")
_filter_chips.visible = kind == "scenery" and tab == "artwork" _filter_chips.visible = kind == "scenery" and tab == "artwork"
@@ -677,49 +948,70 @@ func _usable_screen_size() -> Vector2:
func _update_popup_layout(keep_visible_position: bool = false) -> void: func _update_popup_layout(keep_visible_position: bool = false) -> void:
var previous_position: Vector2i = position var previous_position: Vector2i = position
var in_color_picker: bool = _color_picker_open var in_color_picker: bool = _color_picker_open
var in_plain_choices: bool = _plain_color_choices_open and not in_color_picker
var in_setup: bool = not _setup_kind.is_empty() and not in_color_picker var in_setup: bool = not _setup_kind.is_empty() and not in_color_picker
var scenery_background_gallery: bool = _is_scenery_background_gallery() and not in_setup and not in_color_picker var in_subview: bool = in_setup or in_color_picker or in_plain_choices
var scenery_artwork_gallery: bool = _is_scenery_artwork_gallery() and not in_setup and not in_color_picker var scenery_background_gallery: bool = _is_scenery_background_gallery() and not in_subview
var scenery_artwork_gallery: bool = _is_scenery_artwork_gallery() and not in_subview
var filtered: Array[Dictionary] = _filtered_entries() var filtered: Array[Dictionary] = _filtered_entries()
_tabs.visible = kind == "scenery" and not in_color_picker _tabs.visible = kind == "scenery" and not in_subview
_filter_chips.visible = scenery_artwork_gallery _filter_chips.visible = scenery_artwork_gallery
_position_footer()
_close_button.visible = not in_setup and not in_color_picker _close_button.visible = not in_setup and not in_color_picker
_setup_cancel_button.visible = in_setup _setup_cancel_button.visible = in_setup
_setup_draw_button.visible = in_setup _setup_draw_button.visible = in_setup
_setup_view.visible = in_setup _setup_view.visible = in_setup
_plain_color_view.visible = in_plain_choices
_backgrounds_back_button.visible = in_plain_choices
_color_picker_view.visible = in_color_picker _color_picker_view.visible = in_color_picker
_surface_cards_row.visible = scenery_background_gallery and _has_surface_entries(filtered) _surface_cards_row.visible = scenery_background_gallery and _has_surface_entries(filtered)
_surface_row_heading.visible = _surface_cards_row.visible
_color_back_button.visible = in_color_picker _color_back_button.visible = in_color_picker
_color_use_button.visible = in_color_picker _color_use_button.visible = in_color_picker
_edit_scenery_button.visible = kind == "scenery" and not in_setup and not in_color_picker _edit_scenery_button.visible = kind == "scenery" and not in_setup and not in_color_picker
_footer_spacer.visible = scenery_artwork_gallery _footer_spacer.visible = scenery_artwork_gallery
_empty_label.visible = filtered.is_empty() and not in_setup and not in_color_picker _empty_label.visible = filtered.is_empty() and not in_subview
_grid.visible = not filtered.is_empty() and not in_setup and not in_color_picker _grid.visible = not filtered.is_empty() and not in_subview
_grid_scroll.visible = not filtered.is_empty() or in_setup or in_color_picker _grid_scroll.visible = not filtered.is_empty() or in_subview
_footer.alignment = BoxContainer.ALIGNMENT_BEGIN if scenery_artwork_gallery else (BoxContainer.ALIGNMENT_END if in_setup or in_color_picker else BoxContainer.ALIGNMENT_CENTER) _footer.alignment = BoxContainer.ALIGNMENT_BEGIN if scenery_artwork_gallery or in_subview else BoxContainer.ALIGNMENT_CENTER
_footer.add_theme_constant_override( _footer.add_theme_constant_override(
"separation", "separation",
_theme_integer("popups.asset_selector.footer_gap", 16, 8, 32) if in_setup or in_color_picker or kind == "scenery" else 8 _theme_integer("popups.asset_selector.footer_gap", 16, 8, 32) if in_subview or kind == "scenery" else 8
) )
var available: Vector2 = _usable_screen_size() var available: Vector2 = _usable_screen_size()
var width_ratio: float = 0.98 if in_setup else 0.94 var width_ratio: float = 0.98 if in_subview else (0.96 if kind == "starters" else 0.94)
var max_width: float = maxf(1.0, minf(available.x * width_ratio, available.x - POPUP_SAFE_SCREEN_MARGIN)) var max_width: float = maxf(1.0, minf(available.x * width_ratio, available.x - POPUP_SAFE_SCREEN_MARGIN))
var max_height: float = maxf(1.0, minf(available.y * 0.86, available.y - POPUP_SAFE_SCREEN_MARGIN * 2.0)) var height_ratio: float = _theme_number("popups.asset_selector.starter_viewport_height_ratio", 0.96, 0.7, 0.98) if kind == "starters" else 0.86
var preferred_width: float = CELL_MIN_SIZE.x * COLUMNS + GRID_H_SEPARATION * (COLUMNS - 1) + POPUP_SIDE_PADDING var max_height: float = maxf(1.0, minf(available.y * height_ratio, available.y - POPUP_SAFE_SCREEN_MARGIN * 2.0))
var preferred_width: float = CELL_MIN_SIZE.x * (2 if kind == "starters" else COLUMNS) + GRID_H_SEPARATION * ((2 if kind == "starters" else COLUMNS) - 1) + POPUP_SIDE_PADDING
var preferred_height: float = max_height var preferred_height: float = max_height
if in_color_picker: if kind == "starters":
preferred_width = _theme_number("popups.asset_selector.starter_dialog_width", 1160.0, 440.0, 2400.0)
if in_color_picker or in_plain_choices:
var color_dialog_size: Vector2 = _theme_vector2("popups.dialog.surface_color_size", Vector2(560.0, 640.0)) var color_dialog_size: Vector2 = _theme_vector2("popups.dialog.surface_color_size", Vector2(560.0, 640.0))
preferred_width = color_dialog_size.x preferred_width = color_dialog_size.x
preferred_height = color_dialog_size.y preferred_height = color_dialog_size.y
var popup_width: float = minf(preferred_width, max_width) var popup_width: float = minf(preferred_width, max_width)
_position_footer(popup_width)
var grid_width: float = maxf(1.0, popup_width - POPUP_SIDE_PADDING) var grid_width: float = maxf(1.0, popup_width - POPUP_SIDE_PADDING)
_active_columns = clampi(floori((grid_width + GRID_H_SEPARATION) / (CELL_MIN_SIZE.x + GRID_H_SEPARATION)), 1, COLUMNS) var minimum_card_width: float = CELL_MIN_SIZE.x
_page_capacity = maxi(1, filtered.size()) if scenery_background_gallery or scenery_artwork_gallery else _active_columns * ROWS if kind == "starters":
minimum_card_width = _theme_number("popups.asset_selector.starter_card_min_width", 340.0, 220.0, 800.0)
_active_columns = clampi(floori((grid_width + GRID_H_SEPARATION) / (minimum_card_width + GRID_H_SEPARATION)), 1, 2 if kind == "starters" else COLUMNS)
_page_capacity = maxi(1, filtered.size()) if scenery_background_gallery or scenery_artwork_gallery or kind == "starters" else _active_columns * ROWS
_grid.columns = _active_columns _grid.columns = _active_columns
var card_width: float = minf(CELL_MIN_SIZE.x, (grid_width - GRID_H_SEPARATION * (_active_columns - 1)) / float(_active_columns)) var available_card_width: float = (grid_width - GRID_H_SEPARATION * (_active_columns - 1)) / float(_active_columns)
var card_height_limit: float = 248.0 if kind == "starters" else CELL_MIN_SIZE.y var card_width: float = available_card_width if kind == "starters" else minf(CELL_MIN_SIZE.x, available_card_width)
var card_height: float = minf(card_height_limit, card_width + (58.0 if kind == "starters" else 30.0)) var card_height_limit: float = 248.0 if kind != "starters" else INF
var card_height: float
if kind == "starters":
var preview_horizontal_inset: float = _theme_number("popups.asset_selector.starter_preview_horizontal_inset", 10.0, 0.0, 32.0)
var preview_aspect: float = _theme_number("popups.asset_selector.starter_preview_aspect", 2.0, 1.2, 2.8)
var preview_top_inset: float = _theme_number("popups.asset_selector.starter_preview_top_inset", 6.0, 0.0, 24.0)
var preview_height: float = maxf(1.0, card_width - preview_horizontal_inset * 2.0) / preview_aspect
var text_and_spacing_height: float = _theme_number("popups.asset_selector.starter_card_text_height", 92.0, 72.0, 144.0)
card_height = preview_height + preview_top_inset + text_and_spacing_height
else:
card_height = minf(card_height_limit, card_width + 30.0)
_effective_cell_size = Vector2(maxf(96.0, card_width), maxf(180.0, card_height)) _effective_cell_size = Vector2(maxf(96.0, card_width), maxf(180.0, card_height))
var surface_width: float = minf(_effective_cell_size.x, maxf(96.0, (grid_width - GRID_H_SEPARATION) * 0.5)) var surface_width: float = minf(_effective_cell_size.x, maxf(96.0, (grid_width - GRID_H_SEPARATION) * 0.5))
var surface_height: float = maxf(180.0, minf(card_height_limit, surface_width + 30.0)) var surface_height: float = maxf(180.0, minf(card_height_limit, surface_width + 30.0))
@@ -729,18 +1021,20 @@ func _update_popup_layout(keep_visible_position: bool = false) -> void:
_page = clampi(_page, 0, page_count - 1) _page = clampi(_page, 0, page_count - 1)
var page_start: int = _page * _page_capacity var page_start: int = _page * _page_capacity
var page_items: int = clampi(filtered_count - page_start, 0, _page_capacity) var page_items: int = clampi(filtered_count - page_start, 0, _page_capacity)
var grid_item_count: int = _count_sky_entries(filtered) if scenery_background_gallery else page_items var grid_item_count: int = _count_scene_background_entries(filtered) if scenery_background_gallery else page_items
var grid_rows: int = int(ceil(float(grid_item_count) / float(_active_columns))) if grid_item_count > 0 else 0 var grid_rows: int = int(ceil(float(grid_item_count) / float(_active_columns))) if grid_item_count > 0 else 0
var body_height: float var body_height: float
if in_color_picker: if in_color_picker:
_color_picker_view.set_available_size(Vector2(popup_width, minf(preferred_height, max_height))) _color_picker_view.set_available_size(Vector2(popup_width, minf(preferred_height, max_height)))
body_height = maxf(220.0, _color_picker_view.get_combined_minimum_size().y) body_height = maxf(220.0, _color_picker_view.get_combined_minimum_size().y)
elif in_plain_choices:
body_height = maxf(220.0, _visible_content_minimum_height(_plain_color_view))
elif in_setup: elif in_setup:
body_height = maxf(180.0, _visible_content_minimum_height(_setup_view)) body_height = maxf(180.0, _visible_content_minimum_height(_setup_view))
else: else:
body_height = maxf(120.0, float(grid_rows) * _effective_cell_size.y + float(maxi(0, grid_rows - 1)) * GRID_V_SEPARATION) body_height = maxf(120.0, float(grid_rows) * _effective_cell_size.y + float(maxi(0, grid_rows - 1)) * GRID_V_SEPARATION)
if scenery_background_gallery and _has_surface_entries(filtered): if scenery_background_gallery and _has_surface_entries(filtered):
body_height += _surface_cell_size.y + GRID_V_SEPARATION body_height += _surface_cell_size.y + _surface_row_heading.get_combined_minimum_size().y + GRID_V_SEPARATION * 2.0
if page_items == 0: if page_items == 0:
body_height = maxf(body_height, _empty_label.get_combined_minimum_size().y) body_height = maxf(body_height, _empty_label.get_combined_minimum_size().y)
_tabs.custom_minimum_size.x = grid_width _tabs.custom_minimum_size.x = grid_width
@@ -798,6 +1092,8 @@ func _update_popup_layout(keep_visible_position: bool = false) -> void:
_color_back_button.custom_minimum_size.x = action_width _color_back_button.custom_minimum_size.x = action_width
_color_use_button.custom_minimum_size.x = action_width _color_use_button.custom_minimum_size.x = action_width
size = Vector2i(maxi(1, roundi(popup_width)), maxi(1, roundi(popup_height))) size = Vector2i(maxi(1, roundi(popup_width)), maxi(1, roundi(popup_height)))
_position_footer(float(size.x))
_sync_stage_preview_dimming()
if visible: if visible:
if keep_visible_position: if keep_visible_position:
var max_x: int = maxi(0, floori(available.x - float(size.x) - POPUP_SAFE_SCREEN_MARGIN)) var max_x: int = maxi(0, floori(available.x - float(size.x) - POPUP_SAFE_SCREEN_MARGIN))
@@ -815,7 +1111,7 @@ func _update_popup_layout(keep_visible_position: bool = false) -> void:
func _update_popup_layout_after_layout() -> void: func _update_popup_layout_after_layout() -> void:
await get_tree().process_frame await get_tree().process_frame
if is_inside_tree(): if is_inside_tree():
_update_popup_layout() _update_popup_layout(visible)
func _rebuild() -> void: func _rebuild() -> void:
@@ -827,27 +1123,33 @@ func _rebuild() -> void:
_cell_texrects.clear() _cell_texrects.clear()
var filtered: Array[Dictionary] = _filtered_entries() var filtered: Array[Dictionary] = _filtered_entries()
var in_color_picker: bool = _color_picker_open var in_color_picker: bool = _color_picker_open
var in_plain_choices: bool = _plain_color_choices_open and not in_color_picker
var in_setup: bool = not _setup_kind.is_empty() and not in_color_picker var in_setup: bool = not _setup_kind.is_empty() and not in_color_picker
var scenery_background_gallery: bool = _is_scenery_background_gallery() and not in_setup and not in_color_picker var in_subview: bool = in_setup or in_color_picker or in_plain_choices
var scenery_artwork_gallery: bool = _is_scenery_artwork_gallery() and not in_setup and not in_color_picker var scenery_background_gallery: bool = _is_scenery_background_gallery() and not in_subview
_position_footer() var scenery_artwork_gallery: bool = _is_scenery_artwork_gallery() and not in_subview
_position_footer(float(size.x))
_sync_stage_preview_dimming()
_close_button.visible = not in_setup and not in_color_picker _close_button.visible = not in_setup and not in_color_picker
_setup_view.visible = in_setup _setup_view.visible = in_setup
_plain_color_view.visible = in_plain_choices
_backgrounds_back_button.visible = in_plain_choices
_color_picker_view.visible = in_color_picker _color_picker_view.visible = in_color_picker
_filter_chips.visible = scenery_artwork_gallery _filter_chips.visible = scenery_artwork_gallery
_surface_cards_row.visible = scenery_background_gallery and _has_surface_entries(filtered) _surface_cards_row.visible = scenery_background_gallery and _has_surface_entries(filtered)
_surface_row_heading.visible = _surface_cards_row.visible
_setup_cancel_button.visible = in_setup _setup_cancel_button.visible = in_setup
_setup_draw_button.visible = in_setup _setup_draw_button.visible = in_setup
_color_back_button.visible = in_color_picker _color_back_button.visible = in_color_picker
_color_use_button.visible = in_color_picker _color_use_button.visible = in_color_picker
_edit_scenery_button.visible = kind == "scenery" and not in_setup and not in_color_picker _edit_scenery_button.visible = kind == "scenery" and not in_subview
_make_artwork_button.visible = scenery_artwork_gallery _make_artwork_button.visible = scenery_artwork_gallery
_browse_button.visible = (kind == "stickman" or kind == "prop") and not in_setup and not in_color_picker _browse_button.visible = (kind == "stickman" or kind == "prop") and not in_setup and not in_color_picker
_refresh_button.visible = (kind == "stickman" or kind == "prop") and not in_setup and not in_color_picker _refresh_button.visible = (kind == "stickman" or kind == "prop") and not in_setup and not in_color_picker
_footer_spacer.visible = scenery_artwork_gallery _footer_spacer.visible = scenery_artwork_gallery
_empty_label.visible = filtered.is_empty() and not in_setup and not in_color_picker _empty_label.visible = filtered.is_empty() and not in_subview
_grid.visible = not filtered.is_empty() and not in_setup and not in_color_picker _grid.visible = not filtered.is_empty() and not in_subview
_grid_scroll.visible = not filtered.is_empty() or in_setup or in_color_picker _grid_scroll.visible = not filtered.is_empty() or in_subview
var total := _page_count() var total := _page_count()
var single := total <= 1 var single := total <= 1
_prev_button.visible = not single _prev_button.visible = not single
@@ -856,7 +1158,7 @@ func _rebuild() -> void:
_prev_button.disabled = _page <= 0 _prev_button.disabled = _page <= 0
_next_button.disabled = (_page + 1) * _page_capacity >= filtered.size() _next_button.disabled = (_page + 1) * _page_capacity >= filtered.size()
_page_label.text = "Page %d/%d" % [_page + 1, total] _page_label.text = "Page %d/%d" % [_page + 1, total]
if in_setup or in_color_picker: if in_subview:
_prev_button.visible = false _prev_button.visible = false
_next_button.visible = false _next_button.visible = false
_page_label.visible = false _page_label.visible = false
@@ -869,7 +1171,7 @@ func _rebuild() -> void:
if scenery_background_gallery: if scenery_background_gallery:
for entry: Dictionary in filtered: for entry: Dictionary in filtered:
var background_kind: String = String(entry.get("background_kind", "")) var background_kind: String = String(entry.get("background_kind", ""))
if background_kind == "sky": if background_kind == "sky" or background_kind == "plain":
_grid.add_child(_build_cell(entry)) _grid.add_child(_build_cell(entry))
elif background_kind == "wall_setup" or background_kind == "background_ground_setup": elif background_kind == "wall_setup" or background_kind == "background_ground_setup":
_surface_cards_row.add_child(_build_cell(entry, _surface_cell_size)) _surface_cards_row.add_child(_build_cell(entry, _surface_cell_size))
@@ -879,15 +1181,70 @@ func _rebuild() -> void:
_grid.add_child(_build_cell(filtered[i])) _grid.add_child(_build_cell(filtered[i]))
func _position_footer() -> void: func _position_footer(target_width: float = -1.0) -> void:
var parent := _footer.get_parent() as VBoxContainer var parent := _footer.get_parent() as VBoxContainer
if parent == null: if parent == null:
return return
var target_index: int = parent.get_child_count() - 1 var target_index: int = parent.get_child_count() - 1
if _footer.get_index() != target_index: if _footer.get_index() != target_index:
parent.move_child(_footer, target_index) parent.move_child(_footer, target_index)
if _close_button.get_parent() == _footer and _close_button.get_index() != 0: var in_plain_choices: bool = _plain_color_choices_open and not _color_picker_open
_footer.move_child(_close_button, 0) if in_plain_choices:
var available_width: float = target_width if target_width >= 0.0 else float(size.x)
var stack_actions: bool = available_width < 380.0
var action_container: Control = _plain_footer_column if stack_actions else _plain_footer_row
_plain_footer_row.visible = not stack_actions
_plain_footer_column.visible = stack_actions
_move_footer_control(_backgrounds_back_button, action_container, 0)
if stack_actions:
_move_footer_control(_close_button, action_container, 1)
_move_footer_control(_footer_spacer, _footer, 1)
_footer_spacer.visible = false
_backgrounds_back_button.custom_minimum_size.x = 0.0
_close_button.custom_minimum_size.x = 0.0
_backgrounds_back_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_close_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
else:
_move_footer_control(_footer_spacer, action_container, 1)
_move_footer_control(_close_button, action_container, 2)
_footer_spacer.visible = true
_backgrounds_back_button.custom_minimum_size.x = 148.0
_close_button.custom_minimum_size.x = 136.0
_backgrounds_back_button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
_close_button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
return
_plain_footer_row.visible = false
_plain_footer_column.visible = false
_move_footer_control(_backgrounds_back_button, _footer, 1)
_move_footer_control(_footer_spacer, _footer, 1)
_move_footer_control(_close_button, _footer, 0)
_backgrounds_back_button.custom_minimum_size.x = 148.0
_close_button.custom_minimum_size.x = 136.0
_backgrounds_back_button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
_close_button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
func _move_footer_control(control: Control, target: Control, index: int) -> void:
if control == null or target == null:
return
if control.get_parent() != target:
var old_parent: Node = control.get_parent()
if old_parent != null:
old_parent.remove_child(control)
target.add_child(control)
var safe_index: int = clampi(index, 0, maxi(0, target.get_child_count() - 1))
if control.get_index() != safe_index:
target.move_child(control, safe_index)
func _sync_stage_preview_dimming() -> void:
var should_dim: bool = not (_plain_color_choices_open and kind == "scenery")
if _color_picker_open and _color_picker_owner == &"plain":
should_dim = false
if should_dim == _stage_preview_is_dimmed:
return
_stage_preview_is_dimmed = should_dim
stage_preview_dimming_changed.emit(should_dim)
func _is_scenery_background_gallery() -> bool: func _is_scenery_background_gallery() -> bool:
@@ -898,10 +1255,10 @@ func _is_scenery_artwork_gallery() -> bool:
return kind == "scenery" and _gallery_tab == "artwork" return kind == "scenery" and _gallery_tab == "artwork"
func _count_sky_entries(entries: Array[Dictionary]) -> int: func _count_scene_background_entries(entries: Array[Dictionary]) -> int:
var count: int = 0 var count: int = 0
for entry: Dictionary in entries: for entry: Dictionary in entries:
if String(entry.get("background_kind", "")) == "sky": if String(entry.get("background_kind", "")) in ["sky", "plain"]:
count += 1 count += 1
return count return count
@@ -930,8 +1287,8 @@ func _visible_content_minimum_height(container: VBoxContainer) -> float:
func _build_cell(entry: Dictionary, requested_size: Vector2 = Vector2.ZERO) -> Control: func _build_cell(entry: Dictionary, requested_size: Vector2 = Vector2.ZERO) -> Control:
var key := _entry_key(entry) var key := _entry_key(entry)
var cell: Variant = ASSET_CARD.new() var cell: Variant = ASSET_CARD.new()
# Give scenery cards rounded resting and interaction states. The selected sky # Scene cards have clear rounded resting and interaction states. Selected
# state is applied separately below, so opening the gallery stays neutral. # background state is applied separately below.
var categories: Array = entry.get("tags", []) as Array var categories: Array = entry.get("tags", []) as Array
var category: String = ", ".join(PackedStringArray(categories)) if not categories.is_empty() else String(entry.get("category", entry.get("material_label", ""))) var category: String = ", ".join(PackedStringArray(categories)) if not categories.is_empty() else String(entry.get("category", entry.get("material_label", "")))
var card_size: Vector2 = _effective_cell_size if requested_size == Vector2.ZERO else requested_size var card_size: Vector2 = _effective_cell_size if requested_size == Vector2.ZERO else requested_size
@@ -940,56 +1297,88 @@ func _build_cell(entry: Dictionary, requested_size: Vector2 = Vector2.ZERO) -> C
var thumb_edge: float = minf(_thumbnail_size.x, minf(card_size.x - 20.0, thumb_height_budget)) var thumb_edge: float = minf(_thumbnail_size.x, minf(card_size.x - 20.0, thumb_height_budget))
var thumb_size := Vector2.ONE * maxf(72.0, thumb_edge) var thumb_size := Vector2.ONE * maxf(72.0, thumb_edge)
if kind == "starters": if kind == "starters":
thumb_size = Vector2.ONE * minf(128.0, maxf(72.0, thumb_edge)) var preview_horizontal_inset: float = _theme_number("popups.asset_selector.starter_preview_horizontal_inset", 10.0, 0.0, 32.0)
var preview_aspect: float = _theme_number("popups.asset_selector.starter_preview_aspect", 2.0, 1.2, 2.8)
var preview_width: float = maxf(72.0, card_size.x - preview_horizontal_inset * 2.0)
thumb_size = Vector2(preview_width, preview_width / preview_aspect)
var description: String = "" if is_background_ground_setup else String(entry.get("description", "")) var description: String = "" if is_background_ground_setup else String(entry.get("description", ""))
var card_payload: Dictionary = {"placement_id": _entry_key(entry), "label": String(entry.get("name", entry.get("id", ""))), "icon": String(entry.get("icon", "")), "category": category, "description": description, "thumbnail_size": thumb_size} var card_payload: Dictionary = {"placement_id": _entry_key(entry), "label": String(entry.get("name", entry.get("id", ""))), "icon": String(entry.get("icon", "")), "category": category, "description": description, "thumbnail_size": thumb_size}
if kind == "starters":
card_payload["label_font_size"] = _theme_integer("popups.asset_selector.starter_label_size", 22, 18, 32)
card_payload["label_min_height"] = _theme_integer("popups.asset_selector.starter_label_height", 34, 28, 52)
card_payload["description_font_size"] = _theme_integer("popups.asset_selector.starter_description_size", 20, 16, 30)
card_payload["description_min_height"] = _theme_integer("popups.asset_selector.starter_description_height", 48, 36, 80)
card_payload["preview_corner_radius"] = _theme_integer("popups.asset_selector.starter_preview_corner_radius", 12, 6, 24)
card_payload["preview_horizontal_inset"] = roundi(_theme_number("popups.asset_selector.starter_preview_horizontal_inset", 10.0, 0.0, 32.0))
card_payload["preview_top_inset"] = _theme_integer("popups.asset_selector.starter_preview_top_inset", 6, 0, 24)
if entry.has("background_kind"): if entry.has("background_kind"):
card_payload["background_kind"] = entry["background_kind"] card_payload["background_kind"] = entry["background_kind"]
card_payload["finish_id"] = entry.get("finish_id", "") card_payload["finish_id"] = entry.get("finish_id", "")
card_payload["id"] = entry.get("id", "") card_payload["id"] = entry.get("id", "")
var is_sky_choice: bool = String(entry.get("background_kind", "")) == "sky" var background_kind: String = String(entry.get("background_kind", ""))
var is_current_sky: bool = is_sky_choice and String(entry.get("id", "")) == _current_sky_id var is_scene_background_choice: bool = background_kind == "sky" or background_kind == "plain"
if is_current_sky: var is_current_background: bool = background_kind == String(_current_background_kind) and (
card_payload["status"] = "Current Sky" background_kind == "plain" or String(entry.get("id", "")) == _current_sky_id
)
if is_current_background:
card_payload["status"] = "Current background"
card_payload["status_color"] = _theme_color("mode_colors.edit", Color("#22C6FF")) card_payload["status_color"] = _theme_color("mode_colors.edit", Color("#22C6FF"))
cell.configure(card_payload, _thumbnails.get(key, null), null) cell.configure(card_payload, _thumbnails.get(key, null), null)
if kind == "scenery": if kind == "scenery" or kind == "starters":
var card_button: Button = cell as Button var card_button: Button = cell as Button
var card_border_width: int = _theme_integer("popups.asset_selector.button_border_width", 2, 1, 5) var card_border_width: int = _theme_integer("popups.asset_selector.button_border_width", 2, 1, 5)
var card_corner_radius: int = _theme_integer("popups.asset_selector.corner_radius", 16, 8, 32)
var card_neutral_surface: Color = _theme_color("stage_panels.choice.neutral_surface", Color("#171B24"))
var card_neutral_border: Color = _theme_color("stage_panels.choice.border_color", Color("#FFFFFF33"))
var card_hover_surface: Color = _theme_color("stage_panels.choice.hover_surface", Color("#303A4B"))
var card_selected_surface: Color = _theme_color("stage_panels.choice.selected_surface", Color("#12394A"))
var card_hover_border_width: int = card_border_width + 1
card_button.add_theme_stylebox_override("normal", _make_rounded_style( card_button.add_theme_stylebox_override("normal", _make_rounded_style(
_theme_color("stage_panels.choice.neutral_surface", Color("#171B24")), card_neutral_surface,
_theme_color("stage_panels.choice.border_color", Color("#FFFFFF33")), card_neutral_border,
card_border_width, card_border_width,
_theme_integer("popups.asset_selector.corner_radius", 16, 8, 32) card_corner_radius
)) ))
card_button.add_theme_stylebox_override("hover", _make_rounded_style( card_button.add_theme_stylebox_override("hover", _make_rounded_style(
_theme_color("stage_panels.choice.hover_surface", Color("#303A4B")), card_hover_surface,
_theme_color("mode_colors.edit", Color("#22C6FF")), _theme_color("mode_colors.edit", Color("#22C6FF")),
card_border_width + 1, card_hover_border_width,
_theme_integer("popups.asset_selector.corner_radius", 16, 8, 32) card_corner_radius
)) ))
card_button.add_theme_stylebox_override("pressed", _make_rounded_style( card_button.add_theme_stylebox_override("pressed", _make_rounded_style(
_theme_color("stage_panels.choice.selected_surface", Color("#12394A")), card_selected_surface,
_theme_color("mode_colors.edit", Color("#22C6FF")), _theme_color("mode_colors.edit", Color("#22C6FF")),
card_border_width + 1, card_hover_border_width,
_theme_integer("popups.asset_selector.corner_radius", 16, 8, 32) card_corner_radius
)) ))
card_button.add_theme_stylebox_override("focus", _make_rounded_style( if kind == "starters":
card_button.add_theme_stylebox_override("hover_pressed", _make_rounded_style(
card_selected_surface.lightened(0.05),
_theme_color("mode_colors.edit", Color("#22C6FF")),
card_hover_border_width,
card_corner_radius
))
var focus_color: Color = _theme_color("stage_panels.type.text_color", Color("#F5F7FA")) if kind == "starters" else _theme_color("mode_colors.edit", Color("#22C6FF"))
var focus_style: StyleBoxFlat = _make_rounded_style(
Color(0, 0, 0, 0), Color(0, 0, 0, 0),
_theme_color("mode_colors.edit", Color("#22C6FF")), focus_color,
card_border_width + 1, card_hover_border_width,
_theme_integer("popups.asset_selector.corner_radius", 16, 8, 32) card_corner_radius
)) )
if kind == "starters":
focus_style.set_expand_margin_all(float(card_border_width))
card_button.add_theme_stylebox_override("focus", focus_style)
cell.custom_minimum_size = card_size cell.custom_minimum_size = card_size
cell.focus_mode = Control.FOCUS_ALL cell.focus_mode = Control.FOCUS_ALL
cell.set_meta("entry_id", String(entry.get("id", "")))
cell.activated.connect(func(_payload: Dictionary) -> void: _on_cell_pressed(entry)) cell.activated.connect(func(_payload: Dictionary) -> void: _on_cell_pressed(entry))
if is_sky_choice: if is_scene_background_choice:
cell.button_group = _sky_card_group cell.button_group = _sky_card_group
cell.set_selected(is_current_sky, _theme_color("stage_panels.choice.selected_surface", Color("#12394A")), _theme_color("mode_colors.edit", Color("#22C6FF"))) cell.set_selected(is_current_background, _theme_color("stage_panels.choice.selected_surface", Color("#12394A")), _theme_color("mode_colors.edit", Color("#22C6FF")))
var tex: Texture2D = _thumbnails.get(key, null) var tex: Texture2D = _thumbnails.get(key, null)
if kind == "starters": if kind == "starters":
var preview: Control = STARTER_CARD_PREVIEW.new() as Control var preview: Control = STARTER_CARD_PREVIEW.new() as Control
preview.call("configure", entry) preview.call("configure", entry, thumb_size)
cell.set_preview_control(preview) cell.set_preview_control(preview)
elif entry.has("background_kind"): elif entry.has("background_kind"):
var preview: StageBackgroundCardPreview = BACKGROUND_CARD_PREVIEW.new() as StageBackgroundCardPreview var preview: StageBackgroundCardPreview = BACKGROUND_CARD_PREVIEW.new() as StageBackgroundCardPreview
@@ -1012,6 +1401,10 @@ func _theme_integer(path: String, fallback: int, minimum: int, maximum: int) ->
return fallback if _sandbox_theme == null else _sandbox_theme.integer(path, fallback, minimum, maximum) return fallback if _sandbox_theme == null else _sandbox_theme.integer(path, fallback, minimum, maximum)
func _theme_number(path: String, fallback: float, minimum: float, maximum: float) -> float:
return fallback if _sandbox_theme == null else _sandbox_theme.number(path, fallback, minimum, maximum)
func _theme_vector2(path: String, fallback: Vector2) -> Vector2: func _theme_vector2(path: String, fallback: Vector2) -> Vector2:
if _sandbox_theme == null: if _sandbox_theme == null:
return fallback return fallback
@@ -1054,7 +1447,8 @@ func _apply_chooser_visual_style() -> void:
frame_style.set_corner_radius_all(_theme_integer("popups.asset_selector.surface_corner_radius", 14, 4, 32)) frame_style.set_corner_radius_all(_theme_integer("popups.asset_selector.surface_corner_radius", 14, 4, 32))
preview_frame.add_theme_stylebox_override("panel", frame_style) preview_frame.add_theme_stylebox_override("panel", frame_style)
if _title_label != null: if _title_label != null:
_title_label.add_theme_font_size_override("font_size", _theme_integer("popups.asset_selector.setup_title_size", 30, 22, 48) if kind == "scenery" else 24) var title_size: int = _theme_integer("popups.asset_selector.setup_title_size", 30, 22, 48) if kind == "scenery" else (_theme_integer("popups.asset_selector.starter_title_size", 30, 22, 48) if kind == "starters" else 24)
_title_label.add_theme_font_size_override("font_size", title_size)
_title_label.add_theme_color_override("font_color", text_color) _title_label.add_theme_color_override("font_color", text_color)
_apply_emphasis_font(_title_label) _apply_emphasis_font(_title_label)
for tab: Button in [_backgrounds_tab, _artwork_tab]: for tab: Button in [_backgrounds_tab, _artwork_tab]:
@@ -1096,6 +1490,15 @@ func _apply_chooser_visual_style() -> void:
heading.add_theme_font_size_override("font_size", _theme_integer("popups.asset_selector.setup_heading_size", 26, 18, 48)) heading.add_theme_font_size_override("font_size", _theme_integer("popups.asset_selector.setup_heading_size", 26, 18, 48))
heading.add_theme_color_override("font_color", text_color) heading.add_theme_color_override("font_color", text_color)
_apply_emphasis_font(heading) _apply_emphasis_font(heading)
if _surface_row_heading != null:
_surface_row_heading.add_theme_font_size_override("font_size", _theme_integer("popups.asset_selector.setup_heading_size", 26, 18, 48))
_surface_row_heading.add_theme_color_override("font_color", text_color)
_apply_emphasis_font(_surface_row_heading)
if _plain_color_helper != null:
_plain_color_helper.add_theme_font_size_override("font_size", _theme_integer("stage_panels.type.body_size", 20, 14, 32))
_plain_color_helper.add_theme_color_override("font_color", _theme_color("stage_panels.type.muted_text_color", Color("#AAB2C0")))
_apply_font_to(_plain_color_helper)
_apply_rounded_button(_backgrounds_back_button, false, accent, text_color, neutral, hover, border, radius)
_apply_rounded_button(_setup_cancel_button, false, accent, text_color, neutral, hover, border, radius) _apply_rounded_button(_setup_cancel_button, false, accent, text_color, neutral, hover, border, radius)
_apply_rounded_button(_setup_draw_button, true, accent, text_color, neutral, hover, border, radius) _apply_rounded_button(_setup_draw_button, true, accent, text_color, neutral, hover, border, radius)
_apply_emphasis_font(_setup_draw_button, true) _apply_emphasis_font(_setup_draw_button, true)
+1 -1
View File
@@ -44,7 +44,7 @@ func configure(colors: Array[Color], selected: Color, theme: Variant = null) ->
continue continue
seen[color_key] = true seen[color_key] = true
var button := Button.new() var button := Button.new()
var swatch_size: float = _swatch_size_override if _swatch_size_override > 0.0 else float(_integer("stage_surface_colors.swatch_size", 48)) var swatch_size: float = maxf(44.0, _swatch_size_override if _swatch_size_override > 0.0 else float(_integer("stage_surface_colors.swatch_size", 48)))
button.custom_minimum_size = Vector2(swatch_size, swatch_size) button.custom_minimum_size = Vector2(swatch_size, swatch_size)
button.toggle_mode = true button.toggle_mode = true
button.button_group = _group button.button_group = _group
+52
View File
@@ -61,6 +61,7 @@ var _warned: Dictionary = {}
func _init() -> void: func _init() -> void:
_apply_confirmation_defaults() _apply_confirmation_defaults()
_apply_phase19_defaults()
func load_from(path: String = DEFAULT_PATH) -> bool: func load_from(path: String = DEFAULT_PATH) -> bool:
invalidate_caches() invalidate_caches()
@@ -80,8 +81,59 @@ func load_from(path: String = DEFAULT_PATH) -> bool:
return false return false
_apply_legacy_aliases(parsed as Dictionary) _apply_legacy_aliases(parsed as Dictionary)
_config = _deep_merge(_config, parsed as Dictionary) _config = _deep_merge(_config, parsed as Dictionary)
_apply_phase19_defaults()
return true return true
func _apply_phase19_defaults() -> void:
var grid: Dictionary = _config.get("grid", {}).duplicate(true)
for key: String in ["plain_light_minor", "plain_light_major", "plain_dark_minor", "plain_dark_major"]:
if not grid.has(key):
grid[key] = {
"plain_light_minor": "#11182120",
"plain_light_major": "#11182148",
"plain_dark_minor": "#FFFFFF25",
"plain_dark_major": "#FFFFFF58",
}[key]
_config["grid"] = grid
var popups: Dictionary = _config.get("popups", {}).duplicate(true)
var asset_selector: Dictionary = popups.get("asset_selector", {}).duplicate(true)
asset_selector["compact_swatch_size"] = maxi(44, int(asset_selector.get("compact_swatch_size", 44)))
var starter_defaults: Dictionary = {
"starter_dialog_width": 1160.0,
"starter_viewport_height_ratio": 0.96,
"starter_card_min_width": 340.0,
"starter_preview_aspect": 2.0,
"starter_preview_corner_radius": 12,
"starter_preview_horizontal_inset": 10.0,
"starter_preview_top_inset": 6,
"starter_card_text_height": 108.0,
"starter_title_size": 30,
"starter_label_size": 22,
"starter_label_height": 34,
"starter_description_size": 20,
"starter_description_height": 48,
}
for key: String in starter_defaults:
if not asset_selector.has(key):
asset_selector[key] = starter_defaults[key]
popups["asset_selector"] = asset_selector
_config["popups"] = popups
var overlays: Dictionary = _config.get("overlays", {}).duplicate(true)
var gizmos: Dictionary = overlays.get("gizmos", {}).duplicate(true)
var defaults: Dictionary = {
"backing_color": "#111821E8",
"selection_color": "#F5F7FAE6",
"hover_color": "#FFE66DCC",
"rotate_color": "#4DB9FFE6",
"backing_extra_width": 3.0,
}
for key: String in defaults:
if not gizmos.has(key):
gizmos[key] = defaults[key]
overlays["gizmos"] = gizmos
_config["overlays"] = overlays
func _apply_confirmation_defaults() -> void: func _apply_confirmation_defaults() -> void:
var popups: Dictionary = _config.get("popups", {}).duplicate(true) var popups: Dictionary = _config.get("popups", {}).duplicate(true)
popups["confirmation"] = CONFIRMATION_DEFAULTS.duplicate(true) popups["confirmation"] = CONFIRMATION_DEFAULTS.duplicate(true)
@@ -3,23 +3,29 @@ extends Control
## Reuses the Stage's Sky and wall-finish drawing rules in gallery cards. ## Reuses the Stage's Sky and wall-finish drawing rules in gallery cards.
const SKY_VIEW: Script = preload("res://scripts/stage/scenery/stage_sky_view.gd") const SKY_VIEW: Script = preload("res://scripts/stage/scenery/stage_sky_view.gd")
const BACKGROUND_VIEW: Script = preload("res://scripts/stage/scenery/stage_background_view.gd")
const SURFACE_RENDERER: Script = preload("res://scripts/stage/scenery/stage_surface_renderer.gd") const SURFACE_RENDERER: Script = preload("res://scripts/stage/scenery/stage_surface_renderer.gd")
var _background_kind: String = "" var _background_kind: String = ""
var _preview_id: StringName = &"" var _preview_id: StringName = &""
var _sky_view: StageSkyView var _sky_view: StageSkyView
var _background_view: StageBackgroundView
var _plain_color: Color = Color("#F5EFE0")
func configure(entry: Dictionary) -> void: func configure(entry: Dictionary) -> void:
_background_kind = String(entry.get("background_kind", "")) _background_kind = String(entry.get("background_kind", ""))
_preview_id = StringName(String(entry.get("id", ""))) if _background_kind == "sky" else StringName(String(entry.get("finish_id", ""))) _preview_id = StringName(String(entry.get("id", ""))) if _background_kind == "sky" else StringName(String(entry.get("finish_id", "")))
var raw_plain_color: Variant = entry.get("plain_color", Color("#F5EFE0"))
_plain_color = raw_plain_color if raw_plain_color is Color else Color.from_string(String(raw_plain_color), Color("#F5EFE0"))
clip_contents = true clip_contents = true
mouse_filter = Control.MOUSE_FILTER_IGNORE mouse_filter = Control.MOUSE_FILTER_IGNORE
if _background_kind == "sky": if _background_kind in ["sky", "plain"]:
_sky_view = SKY_VIEW.new() as StageSkyView _background_view = BACKGROUND_VIEW.new() as StageBackgroundView
_sky_view.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) _background_view.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
_sky_view.set_sky(_preview_id) _background_view.set_background(StringName(_background_kind), _preview_id, _plain_color)
add_child(_sky_view) add_child(_background_view)
_sky_view = _background_view.get_sky_view()
var frame: Panel = Panel.new() var frame: Panel = Panel.new()
frame.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) frame.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
frame.mouse_filter = Control.MOUSE_FILTER_IGNORE frame.mouse_filter = Control.MOUSE_FILTER_IGNORE
@@ -35,6 +41,8 @@ func configure(entry: Dictionary) -> void:
func _draw() -> void: func _draw() -> void:
if _background_kind == "plain":
return
if _background_kind == "wall" and SURFACE_RENDERER.is_wall_finish(_preview_id): if _background_kind == "wall" and SURFACE_RENDERER.is_wall_finish(_preview_id):
var wall_tint: Color = Color("#7FA36C") if _preview_id == &"finish_wall_paint" else Color.WHITE var wall_tint: Color = Color("#7FA36C") if _preview_id == &"finish_wall_paint" else Color.WHITE
# The preview rect is already small and clipped, so draw its full pattern directly. # The preview rect is already small and clipped, so draw its full pattern directly.
@@ -0,0 +1,74 @@
class_name StageBackgroundView
extends Control
## Shared full-rect backdrop for the live Stage and still card previews.
const SKY_VIEW_SCRIPT := preload("res://scripts/stage/scenery/stage_sky_view.gd")
var _sky_view: StageSkyView
var _plain_fill: ColorRect
var _bound_camera: Camera2D
var _background_kind: StringName = &"sky"
var _sky_id: StringName = &"sky_neutral"
var _plain_color: Color = Color("#F5EFE0")
func _ready() -> void:
mouse_filter = Control.MOUSE_FILTER_IGNORE
if _sky_view == null:
_sky_view = SKY_VIEW_SCRIPT.new() as StageSkyView
_sky_view.name = "StageSkyView"
_sky_view.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
_sky_view.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(_sky_view)
if _plain_fill == null:
_plain_fill = ColorRect.new()
_plain_fill.name = "PlainFill"
_plain_fill.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
_plain_fill.mouse_filter = Control.MOUSE_FILTER_IGNORE
_plain_fill.color = _opaque(_plain_color)
add_child(_plain_fill)
_refresh_children()
func set_background(kind: StringName, sky_id: StringName, plain_color: Color) -> void:
_background_kind = &"plain" if kind == &"plain" else &"sky"
_sky_id = sky_id
_plain_color = _opaque(plain_color)
_refresh_children()
func bind_camera(camera: Camera2D) -> void:
_bound_camera = camera
if _sky_view != null:
_sky_view.bind_camera(_bound_camera if _background_kind == &"sky" else null)
func apply_theme(stage_theme: SandboxTheme) -> void:
if _sky_view != null:
_sky_view.apply_theme(stage_theme)
func get_sky_view() -> StageSkyView:
return _sky_view
func get_background_kind() -> StringName:
return _background_kind
func get_plain_color() -> Color:
return _plain_color
func _refresh_children() -> void:
if _sky_view == null or _plain_fill == null:
return
_sky_view.set_sky(_sky_id)
_sky_view.visible = _background_kind == &"sky"
_sky_view.bind_camera(_bound_camera if _background_kind == &"sky" else null)
_plain_fill.color = _plain_color
_plain_fill.visible = _background_kind == &"plain"
func _opaque(color: Color) -> Color:
return Color(color.r, color.g, color.b, 1.0)
@@ -0,0 +1 @@
uid://dc72udajou30y
@@ -6,6 +6,7 @@ const STAGE_SCENE_IO := preload("res://scripts/stage/stage_scene_io.gd")
const STAGE_SCENE_ADAPTER := preload("res://scripts/editors/stage/stage_scene_adapter.gd") const STAGE_SCENE_ADAPTER := preload("res://scripts/editors/stage/stage_scene_adapter.gd")
const STAGE_SPAWNER := preload("res://scripts/stage/stage_spawner.gd") const STAGE_SPAWNER := preload("res://scripts/stage/stage_spawner.gd")
const STAGE_SKY_VIEW := preload("res://scripts/stage/scenery/stage_sky_view.gd") const STAGE_SKY_VIEW := preload("res://scripts/stage/scenery/stage_sky_view.gd")
const STAGE_BACKGROUND_VIEW := preload("res://scripts/stage/scenery/stage_background_view.gd")
const PROP_BLOCK := preload("res://scripts/props/prop_block.gd") const PROP_BLOCK := preload("res://scripts/props/prop_block.gd")
const PREVIEW_SIZE := Vector2i(256, 256) const PREVIEW_SIZE := Vector2i(256, 256)
@@ -14,14 +15,16 @@ const REFERENCE_VIEWPORT_SIZE := Vector2(1280.0, 720.0)
var _viewport: SubViewport var _viewport: SubViewport
var _sky_view: StageSkyView var _sky_view: StageSkyView
var _background_view: StageBackgroundView
var _world: Node2D var _world: Node2D
var _loaded_nodes: Array[Node2D] = [] var _loaded_nodes: Array[Node2D] = []
var _scene_valid: bool = false var _scene_valid: bool = false
func configure(entry: Dictionary) -> void: func configure(entry: Dictionary, requested_preview_size: Vector2 = Vector2.ZERO) -> void:
name = "StarterScenePreview" name = "StarterScenePreview"
custom_minimum_size = Vector2(128.0, 128.0) var resolved_preview_size: Vector2 = requested_preview_size if requested_preview_size.x > 0.0 and requested_preview_size.y > 0.0 else Vector2(PREVIEW_SIZE)
custom_minimum_size = resolved_preview_size
mouse_filter = Control.MOUSE_FILTER_IGNORE mouse_filter = Control.MOUSE_FILTER_IGNORE
stretch = true stretch = true
texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR
@@ -31,36 +34,40 @@ func configure(entry: Dictionary) -> void:
return return
var data: Dictionary = result.get("data", {}) as Dictionary var data: Dictionary = result.get("data", {}) as Dictionary
_scene_valid = true _scene_valid = true
_build_preview_viewport(data) _build_preview_viewport(data, resolved_preview_size)
func has_preview_scene() -> bool: func has_preview_scene() -> bool:
return _scene_valid and _viewport != null and _sky_view != null and _world != null return _scene_valid and _viewport != null and _background_view != null and _world != null
func get_loaded_object_count() -> int: func get_loaded_object_count() -> int:
return _loaded_nodes.size() return _loaded_nodes.size()
func _build_preview_viewport(data: Dictionary) -> void: func _build_preview_viewport(data: Dictionary, requested_preview_size: Vector2) -> void:
_viewport = SubViewport.new() _viewport = SubViewport.new()
_viewport.name = "PreviewViewport" _viewport.name = "PreviewViewport"
_viewport.size = PREVIEW_SIZE _viewport.size = Vector2i(maxi(1, roundi(requested_preview_size.x)), maxi(1, roundi(requested_preview_size.y)))
_viewport.world_2d = World2D.new() _viewport.world_2d = World2D.new()
_viewport.transparent_bg = false _viewport.transparent_bg = false
_viewport.render_target_update_mode = SubViewport.UPDATE_DISABLED _viewport.render_target_update_mode = SubViewport.UPDATE_DISABLED
add_child(_viewport) add_child(_viewport)
var sky_layer := CanvasLayer.new() var background_layer := CanvasLayer.new()
sky_layer.name = "PreviewSky" background_layer.name = "PreviewBackgroundLayer"
sky_layer.layer = -1 background_layer.layer = -1
_viewport.add_child(sky_layer) _viewport.add_child(background_layer)
_sky_view = STAGE_SKY_VIEW.new() as StageSkyView _background_view = STAGE_BACKGROUND_VIEW.new() as StageBackgroundView
_sky_view.name = "SkyView" _background_view.name = "StageBackgroundView"
_sky_view.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) _background_view.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
_sky_view.mouse_filter = Control.MOUSE_FILTER_IGNORE _background_view.set_background(
_sky_view.set_sky(StringName(String(data.get("sky_id", "sky_neutral")))) StringName(String(data.get("background_kind", "sky"))),
sky_layer.add_child(_sky_view) StringName(String(data.get("sky_id", "sky_neutral"))),
STAGE_SCENE_IO.color_from_data(data.get("plain_color", STAGE_SCENE_IO.DEFAULT_PLAIN_COLOR), Color("#F5EFE0"))
)
background_layer.add_child(_background_view)
_sky_view = _background_view.get_sky_view()
_world = Node2D.new() _world = Node2D.new()
_world.name = "PreviewWorld" _world.name = "PreviewWorld"
@@ -85,27 +92,30 @@ func _build_preview_viewport(data: Dictionary) -> void:
func _fit_scene_to_preview(camera_state: Dictionary) -> void: func _fit_scene_to_preview(camera_state: Dictionary) -> void:
if _world == null or not is_instance_valid(_world): if _world == null or not is_instance_valid(_world):
return return
var preview_frame: Dictionary = _preview_transform_for_camera(camera_state) var preview_frame: Dictionary = _preview_transform_for_camera(camera_state, Vector2(_viewport.size))
var preview_scale: float = float(preview_frame["scale"]) var preview_scale: float = float(preview_frame["scale"])
_world.scale = Vector2.ONE * preview_scale _world.scale = Vector2.ONE * preview_scale
_world.position = preview_frame["position"] as Vector2 _world.position = preview_frame["position"] as Vector2
_viewport.render_target_update_mode = SubViewport.UPDATE_ONCE _viewport.render_target_update_mode = SubViewport.UPDATE_ONCE
static func _preview_transform_for_camera(camera_state: Dictionary) -> Dictionary: static func _preview_transform_for_camera(camera_state: Dictionary, preview_size: Vector2 = Vector2(PREVIEW_SIZE)) -> Dictionary:
var camera_position: Vector2 = STAGE_SCENE_IO.data_to_vector(camera_state.get("position"), Vector2.ZERO) var camera_position: Vector2 = STAGE_SCENE_IO.data_to_vector(camera_state.get("position"), Vector2.ZERO)
var camera_zoom: float = float(camera_state.get("zoom", 0.5)) var camera_zoom: float = float(camera_state.get("zoom", 0.5))
if not is_finite(camera_zoom) or camera_zoom <= 0.0: if not is_finite(camera_zoom) or camera_zoom <= 0.0:
camera_zoom = 0.5 camera_zoom = 0.5
var safe_preview_size: Vector2 = preview_size if preview_size.x > 0.0 and preview_size.y > 0.0 else Vector2(PREVIEW_SIZE)
var preview_aspect: float = safe_preview_size.x / safe_preview_size.y
var square_world_extent: float = REFERENCE_VIEWPORT_SIZE.y / camera_zoom var square_world_extent: float = REFERENCE_VIEWPORT_SIZE.y / camera_zoom
var focus_size := Vector2(square_world_extent * preview_aspect, square_world_extent)
var focus_rect := Rect2( var focus_rect := Rect2(
camera_position - Vector2.ONE * square_world_extent * 0.5, camera_position - focus_size * 0.5,
Vector2.ONE * square_world_extent focus_size
) )
var usable_size: Vector2 = Vector2(PREVIEW_SIZE) - Vector2.ONE * PREVIEW_MARGIN * 2.0 var usable_size: Vector2 = safe_preview_size - Vector2(PREVIEW_MARGIN * 2.0, PREVIEW_MARGIN * 2.0)
var preview_scale: float = minf(usable_size.x / focus_rect.size.x, usable_size.y / focus_rect.size.y) var preview_scale: float = minf(usable_size.x / focus_rect.size.x, usable_size.y / focus_rect.size.y)
return { return {
"focus_rect": focus_rect, "focus_rect": focus_rect,
"scale": preview_scale, "scale": preview_scale,
"position": Vector2(PREVIEW_SIZE) * 0.5 - camera_position * preview_scale, "position": safe_preview_size * 0.5 - camera_position * preview_scale,
} }
@@ -29,14 +29,16 @@ func _draw() -> void:
var rect: Rect2 = Rect2(Vector2(3.0, 3.0), size - Vector2(6.0, 6.0)) var rect: Rect2 = Rect2(Vector2(3.0, 3.0), size - Vector2(6.0, 6.0))
if rect.size.x <= 0.0 or rect.size.y <= 0.0: if rect.size.x <= 0.0 or rect.size.y <= 0.0:
return return
if surface_kind == &"background_ground": if surface_kind == &"plain_background":
draw_rect(rect, Color(tint.r, tint.g, tint.b, 1.0), true)
elif surface_kind == &"background_ground":
SURFACE_RENDERER.draw_background(self, rect, finish_id, tint, Vector2.ZERO, Vector2.ONE, false) SURFACE_RENDERER.draw_background(self, rect, finish_id, tint, Vector2.ZERO, Vector2.ONE, false)
else: else:
SURFACE_RENDERER.draw_wall(self, rect, finish_id, tint, Vector2.ZERO, Vector2.ONE, false) SURFACE_RENDERER.draw_wall(self, rect, finish_id, tint, Vector2.ZERO, Vector2.ONE, false)
var radius: float = minf(corner_radius, minf(rect.size.x, rect.size.y) * 0.5) var radius: float = minf(corner_radius, minf(rect.size.x, rect.size.y) * 0.5)
if radius > 0.0: if radius > 0.0:
var wall: bool = surface_kind != &"background_ground" var wall: bool = surface_kind != &"background_ground"
var base_color: Color = SURFACE_RENDERER.surface_base_color(finish_id, tint, wall) var base_color: Color = Color(tint.r, tint.g, tint.b, 1.0) if surface_kind == &"plain_background" else SURFACE_RENDERER.surface_base_color(finish_id, tint, wall)
_draw_rounded_corner(rect, radius, base_color, outside_color, 0) _draw_rounded_corner(rect, radius, base_color, outside_color, 0)
_draw_rounded_corner(rect, radius, base_color, outside_color, 1) _draw_rounded_corner(rect, radius, base_color, outside_color, 1)
_draw_rounded_corner(rect, radius, base_color, outside_color, 2) _draw_rounded_corner(rect, radius, base_color, outside_color, 2)
+31 -4
View File
@@ -54,6 +54,13 @@ const MAX_SCALE: float = 20.0
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
var camera: Camera2D = null var camera: Camera2D = null
var _selection_backing_color: Color = Color("#111821E8")
var _selection_core_color: Color = Color(1.0, 1.0, 1.0, 0.9)
var _hover_backing_color: Color = Color("#111821E8")
var _hover_core_color: Color = Color(1.0, 0.9, 0.2, 0.5)
var _rotate_backing_color: Color = Color("#111821E8")
var _rotate_core_color: Color = Color(0.3, 0.6, 1.0, 0.9)
var _outline_extra_width: float = 3.0
## When > 0, translation drags snap to this grid size (0 = off). ## When > 0, translation drags snap to this grid size (0 = off).
var snap_size: float = 0.0 var snap_size: float = 0.0
@@ -105,6 +112,19 @@ func set_snap_size(size: float) -> void:
snap_size = maxf(size, 0.0) snap_size = maxf(size, 0.0)
func apply_theme(stage_theme: SandboxTheme) -> void:
if stage_theme == null:
return
_selection_backing_color = stage_theme.color("overlays.gizmos.backing_color", Color("#111821E8"))
_selection_core_color = stage_theme.color("overlays.gizmos.selection_color", SELECTION_COLOR)
_hover_backing_color = stage_theme.color("overlays.gizmos.backing_color", Color("#111821E8"))
_hover_core_color = stage_theme.color("overlays.gizmos.hover_color", HOVER_COLOR)
_rotate_backing_color = stage_theme.color("overlays.gizmos.backing_color", Color("#111821E8"))
_rotate_core_color = stage_theme.color("overlays.gizmos.rotate_color", ROTATE_COLOR)
_outline_extra_width = stage_theme.number("overlays.gizmos.backing_extra_width", 3.0, 1.0, 8.0)
queue_redraw()
func set_box_rect(rect: Rect2) -> void: func set_box_rect(rect: Rect2) -> void:
_box_rect = rect _box_rect = rect
queue_redraw() queue_redraw()
@@ -253,16 +273,18 @@ func _draw() -> void:
return return
var zoom := _zoom() var zoom := _zoom()
if _hovered != null and is_instance_valid(_hovered) and not _hovered.is_queued_for_deletion() and not _targets.has(_hovered): if _hovered != null and is_instance_valid(_hovered) and not _hovered.is_queued_for_deletion() and not _targets.has(_hovered):
draw_rect(_target_bounds(_hovered), HOVER_COLOR, false, HOVER_WIDTH / zoom) _draw_halo_rect(_target_bounds(_hovered), _hover_core_color, HOVER_WIDTH / zoom, _hover_backing_color)
# A selection outline for every selected object. # A selection outline for every selected object.
for node: Node2D in _targets: for node: Node2D in _targets:
if node != null and is_instance_valid(node): if node != null and is_instance_valid(node):
draw_rect(_target_bounds(node), SELECTION_COLOR, false, SELECTION_WIDTH / zoom) _draw_halo_rect(_target_bounds(node), _selection_core_color, SELECTION_WIDTH / zoom, _selection_backing_color)
# Rotate ring only for a single selection. # Rotate ring only for a single selection.
if _transform_handles_visible and _targets.size() == 1 and is_instance_valid(_targets[0]): if _transform_handles_visible and _targets.size() == 1 and is_instance_valid(_targets[0]):
var rect: Rect2 = _target_bounds(_targets[0]) var rect: Rect2 = _target_bounds(_targets[0])
if not _is_scenery_target(_targets[0]): if not _is_scenery_target(_targets[0]):
draw_arc(rect.get_center(), _rotate_ring_radius(rect), 0.0, TAU, 64, ROTATE_COLOR, ROTATE_WIDTH / zoom, true) var ring_radius: float = _rotate_ring_radius(rect)
draw_arc(rect.get_center(), ring_radius, 0.0, TAU, 64, _rotate_backing_color, ROTATE_WIDTH / zoom + _outline_extra_width / zoom, true)
draw_arc(rect.get_center(), ring_radius, 0.0, TAU, 64, _rotate_core_color, ROTATE_WIDTH / zoom, true)
if _is_scenery_target(_targets[0]): if _is_scenery_target(_targets[0]):
for corner: Vector2 in _corners(rect): for corner: Vector2 in _corners(rect):
draw_circle(corner, 11.0 / zoom, Color("#111821E8")) draw_circle(corner, 11.0 / zoom, Color("#111821E8"))
@@ -275,7 +297,7 @@ func _draw() -> void:
draw_line(corner + Vector2(-half, 0.0), corner + Vector2(half, 0.0), SELECTION_COLOR, 1.5 / zoom) draw_line(corner + Vector2(-half, 0.0), corner + Vector2(half, 0.0), SELECTION_COLOR, 1.5 / zoom)
draw_line(corner + Vector2(0.0, -half), corner + Vector2(0.0, half), SELECTION_COLOR, 1.5 / zoom) draw_line(corner + Vector2(0.0, -half), corner + Vector2(0.0, half), SELECTION_COLOR, 1.5 / zoom)
if _box_rect.size != Vector2.ZERO: if _box_rect.size != Vector2.ZERO:
draw_rect(_box_rect.abs(), HOVER_COLOR, false, HOVER_WIDTH / zoom) _draw_halo_rect(_box_rect.abs(), _hover_core_color, HOVER_WIDTH / zoom, _hover_backing_color)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Internal helpers # Internal helpers
@@ -287,6 +309,11 @@ func _zoom() -> float:
return 1.0 return 1.0
func _draw_halo_rect(rect: Rect2, core_color: Color, core_width: float, backing_color: Color) -> void:
draw_rect(rect, backing_color, false, core_width + _outline_extra_width / _zoom())
draw_rect(rect, core_color, false, core_width)
func _rotate_ring_radius(rect: Rect2) -> float: func _rotate_ring_radius(rect: Rect2) -> float:
return rect.size.length() * 0.5 + ROTATE_HANDLE_MARGIN_PX / _zoom() return rect.size.length() * 0.5 + ROTATE_HANDLE_MARGIN_PX / _zoom()
+34 -2
View File
@@ -9,6 +9,12 @@ extends Node2D
var camera: Camera2D = null var camera: Camera2D = null
var grid_size: float = 15.0 var grid_size: float = 15.0
var enabled: bool = true var enabled: bool = true
var _plain_background_active: bool = false
var _plain_background_color: Color = Color("#F5EFE0")
var _plain_light_minor_color: Color = Color("#11182120")
var _plain_light_major_color: Color = Color("#11182148")
var _plain_dark_minor_color: Color = Color("#FFFFFF25")
var _plain_dark_major_color: Color = Color("#FFFFFF58")
const GRID_COLOR := Color(1.0, 1.0, 1.0, 0.08) const GRID_COLOR := Color(1.0, 1.0, 1.0, 0.08)
const MAJOR_COLOR := Color(1.0, 1.0, 1.0, 0.16) const MAJOR_COLOR := Color(1.0, 1.0, 1.0, 0.16)
@@ -19,6 +25,23 @@ func _process(_delta: float) -> void:
queue_redraw() queue_redraw()
func set_background_treatment(
plain_active: bool,
plain_color: Color,
light_minor: Color,
light_major: Color,
dark_minor: Color,
dark_major: Color
) -> void:
_plain_background_active = plain_active
_plain_background_color = Color(plain_color.r, plain_color.g, plain_color.b, 1.0)
_plain_light_minor_color = light_minor
_plain_light_major_color = light_major
_plain_dark_minor_color = dark_minor
_plain_dark_major_color = dark_major
queue_redraw()
func _draw() -> void: func _draw() -> void:
if not enabled or grid_size <= 0.0: if not enabled or grid_size <= 0.0:
return return
@@ -34,13 +57,22 @@ func _draw() -> void:
var x := floorf(rect.position.x / grid_size) * grid_size var x := floorf(rect.position.x / grid_size) * grid_size
while x <= rect.end.x: while x <= rect.end.x:
var grid_index := int(round(x / grid_size)) var grid_index := int(round(x / grid_size))
var color := MAJOR_COLOR if grid_index % MAJOR_EVERY == 0 else GRID_COLOR var color: Color = _grid_color(grid_index % MAJOR_EVERY == 0)
draw_line(Vector2(x, rect.position.y), Vector2(x, rect.end.y), color, line_width) draw_line(Vector2(x, rect.position.y), Vector2(x, rect.end.y), color, line_width)
x += grid_size x += grid_size
var y := floorf(rect.position.y / grid_size) * grid_size var y := floorf(rect.position.y / grid_size) * grid_size
while y <= rect.end.y: while y <= rect.end.y:
var grid_index := int(round(y / grid_size)) var grid_index := int(round(y / grid_size))
var color := MAJOR_COLOR if grid_index % MAJOR_EVERY == 0 else GRID_COLOR var color: Color = _grid_color(grid_index % MAJOR_EVERY == 0)
draw_line(Vector2(rect.position.x, y), Vector2(rect.end.x, y), color, line_width) draw_line(Vector2(rect.position.x, y), Vector2(rect.end.x, y), color, line_width)
y += grid_size y += grid_size
func _grid_color(is_major: bool) -> Color:
if not _plain_background_active:
return MAJOR_COLOR if is_major else GRID_COLOR
var light_fill: bool = _plain_background_color.get_luminance() >= 0.55
if light_fill:
return _plain_light_major_color if is_major else _plain_light_minor_color
return _plain_dark_major_color if is_major else _plain_dark_minor_color
+28 -6
View File
@@ -3,7 +3,8 @@ extends RefCounted
## JSON boundary for Sandbox Stage documents. This class deliberately has no ## JSON boundary for Sandbox Stage documents. This class deliberately has no
## scene-tree dependencies, which makes rejected documents non-destructive. ## scene-tree dependencies, which makes rejected documents non-destructive.
const FILE_VERSION: String = "1.6" const FILE_VERSION: String = "1.7"
const DEFAULT_PLAIN_COLOR: String = "#F5EFE0"
const SURFACE_RENDERER := preload("res://scripts/stage/scenery/stage_surface_renderer.gd") const SURFACE_RENDERER := preload("res://scripts/stage/scenery/stage_surface_renderer.gd")
const CONTENT_PATHS := preload("res://scripts/shared/content_paths.gd") const CONTENT_PATHS := preload("res://scripts/shared/content_paths.gd")
const ACTION_REGISTRY := preload("res://scripts/stage/action_registry.gd") const ACTION_REGISTRY := preload("res://scripts/stage/action_registry.gd")
@@ -185,11 +186,13 @@ static func _migrate_to_current(data: Dictionary) -> Dictionary:
prop_entry["wobble_on_impact"] = false prop_entry["wobble_on_impact"] = false
_assign_legacy_depths(current.get("objects", [])) _assign_legacy_depths(current.get("objects", []))
return current return current
if version not in ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5"]: if version not in ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6"]:
return {} return {}
var migrated: Dictionary = data.duplicate(true) var migrated: Dictionary = data.duplicate(true)
if version != "1.5": if version not in ["1.5", "1.6"]:
migrated["sky_id"] = "sky_neutral" migrated["sky_id"] = "sky_neutral"
migrated["background_kind"] = "sky"
migrated["plain_color"] = DEFAULT_PLAIN_COLOR
for raw: Variant in migrated.get("objects", []): for raw: Variant in migrated.get("objects", []):
if not raw is Dictionary: if not raw is Dictionary:
continue continue
@@ -203,9 +206,9 @@ static func _migrate_to_current(data: Dictionary) -> Dictionary:
object["next_use_spot_number"] = object.get("next_use_spot_number", 1) object["next_use_spot_number"] = object.get("next_use_spot_number", 1)
if not object.has("wobble_on_impact"): if not object.has("wobble_on_impact"):
object["wobble_on_impact"] = false object["wobble_on_impact"] = false
if version != "1.5" and String(object.get("type", "")) == "terrain" and String(object.get("asset_id", "")) == "ground": if version not in ["1.5", "1.6"] and String(object.get("type", "")) == "terrain" and String(object.get("asset_id", "")) == "ground":
object["finish_id"] = "finish_ground_legacy" object["finish_id"] = "finish_ground_legacy"
if String(object.get("type", "")) == "wall_panel": if version != "1.6" and String(object.get("type", "")) == "wall_panel":
_migrate_legacy_wall_tint(object) _migrate_legacy_wall_tint(object)
migrated["version"] = FILE_VERSION migrated["version"] = FILE_VERSION
_assign_legacy_depths(migrated.get("objects", [])) _assign_legacy_depths(migrated.get("objects", []))
@@ -254,9 +257,15 @@ static func _assign_legacy_depths(raw_objects: Variant) -> void:
roles["depth"] = PROP_STAGE_ROLES.DEPTH_FRONT if characters_before > characters_after else PROP_STAGE_ROLES.DEPTH_BEHIND roles["depth"] = PROP_STAGE_ROLES.DEPTH_FRONT if characters_before > characters_after else PROP_STAGE_ROLES.DEPTH_BEHIND
static func _validate_root(data: Dictionary) -> Dictionary: static func _validate_root(data: Dictionary) -> Dictionary:
var sky_id: Variant = data.get("sky_id", "sky_neutral") var background_kind: Variant = data.get("background_kind", null)
if not background_kind is String or not ["sky", "plain"].has(String(background_kind)):
return {"ok": false, "error": "Scene background kind is invalid."}
var sky_id: Variant = data.get("sky_id", null)
if not sky_id is String or not SKY_IDS.has(String(sky_id)): if not sky_id is String or not SKY_IDS.has(String(sky_id)):
return {"ok": false, "error": "Scene Sky is invalid."} return {"ok": false, "error": "Scene Sky is invalid."}
var plain_color: Variant = data.get("plain_color", null)
if not _valid_opaque_hex_color(plain_color):
return {"ok": false, "error": "Scene Plain Background color is invalid."}
var seen: Dictionary = {} var seen: Dictionary = {}
var seen_stage_ids: Dictionary = {} var seen_stage_ids: Dictionary = {}
for raw: Variant in data["objects"]: for raw: Variant in data["objects"]:
@@ -346,6 +355,19 @@ static func _valid_color(value: Variant) -> bool:
return true return true
static func _valid_opaque_hex_color(value: Variant) -> bool:
if not value is String:
return false
var raw: String = String(value).strip_edges()
if raw.length() != 7 or not raw.begins_with("#"):
return false
const HEX_DIGITS: String = "0123456789abcdefABCDEF"
for index: int in range(1, raw.length()):
if not HEX_DIGITS.contains(raw.substr(index, 1)):
return false
return true
static func _valid_rect_data(value: Variant) -> bool: static func _valid_rect_data(value: Variant) -> bool:
if not value is Dictionary: if not value is Dictionary:
return false return false
+5 -2
View File
@@ -46,7 +46,7 @@ func _test_migration_and_schema() -> void:
var legacy: Dictionary = {"version": version, "objects": [{"file_id": "prop_a", "type": "prop"}]} var legacy: Dictionary = {"version": version, "objects": [{"file_id": "prop_a", "type": "prop"}]}
var migrated: Dictionary = STAGE_SCENE_IO._migrate_to_current(legacy) var migrated: Dictionary = STAGE_SCENE_IO._migrate_to_current(legacy)
var entry: Dictionary = migrated["objects"][0] var entry: Dictionary = migrated["objects"][0]
_expect(String(migrated["version"]) == "1.3" and entry.get("use_spots") == [] and int(entry.get("next_use_spot_number", 0)) == 1, "%s prop receives v1.3 empty Use spot defaults" % version) _expect(String(migrated["version"]) == STAGE_SCENE_IO.FILE_VERSION and entry.get("use_spots") == [] and int(entry.get("next_use_spot_number", 0)) == 1, "%s prop receives current-format empty Use spot defaults" % version)
var valid_root: Dictionary = _valid_root() var valid_root: Dictionary = _valid_root()
_expect(bool(STAGE_SCENE_IO._validate_root(valid_root).get("ok", false)), "valid Use spot data passes root validation") _expect(bool(STAGE_SCENE_IO._validate_root(valid_root).get("ok", false)), "valid Use spot data passes root validation")
var duplicate: Dictionary = _valid_root() var duplicate: Dictionary = _valid_root()
@@ -176,7 +176,10 @@ func _on_use_failed(reason_code: String, _prop: PropBlock, _spot_id: String) ->
func _valid_root() -> Dictionary: func _valid_root() -> Dictionary:
return { return {
"version": "1.3", "version": STAGE_SCENE_IO.FILE_VERSION,
"sky_id": "sky_neutral",
"background_kind": "sky",
"plain_color": STAGE_SCENE_IO.DEFAULT_PLAIN_COLOR,
"objects": [{ "objects": [{
"file_id": "prop_file", "file_id": "prop_file",
"type": "prop", "type": "prop",
+430
View File
@@ -0,0 +1,430 @@
extends SceneTree
const SANDBOX_STAGE: PackedScene = preload("res://scenes/stage/sandbox_stage.tscn")
const STAGE_SCENE_IO: Script = preload("res://scripts/stage/stage_scene_io.gd")
const PLAIN_STARTER_PATH: String = "res://content/stages/starters/plain_background.scene"
var _checks: int = 0
var _failures: int = 0
var _stage: SandboxStage
func _initialize() -> void:
call_deferred("_run")
func _run() -> void:
root.size = Vector2i(1280, 720)
_test_version_migration_and_validation()
var starter_result: Dictionary = STAGE_SCENE_IO.read_file(PLAIN_STARTER_PATH)
_expect(bool(starter_result.get("ok", false)), "Plain Background starter is valid v1.7 data")
_stage = SANDBOX_STAGE.instantiate() as SandboxStage
root.add_child(_stage)
await process_frame
await process_frame
_test_live_backdrop_default()
await _save_visual_capture("phase19_open_sky_stage.png")
await _test_plain_background_picker_flow()
await _test_draft_cancel_on_mode_switch()
await _test_draft_cancel_on_popup_hide()
await _test_draft_cancel_on_scene_replacement(starter_result.get("data", {}) as Dictionary)
_test_recent_color_history_limit()
print("----------------------------------------")
if _failures == 0:
print("RESULT: ALL PASSED (%d checks)" % _checks)
quit(0)
else:
print("RESULT: %d FAILURE(S) out of %d checks" % [_failures, _checks])
quit(1)
func _expect(condition: bool, message: String) -> void:
_checks += 1
if condition:
print("PASS: " + message)
else:
_failures += 1
push_error("Phase 19 Plain Background check failed: " + message)
func _test_version_migration_and_validation() -> void:
for version: String in ["1.0", "1.4", "1.5", "1.6"]:
var legacy: Dictionary = {
"version": version,
"scene_name": "Migration fixture",
"sky_id": "sky_sunset",
"camera": {"position": {"x": 0.0, "y": -400.0}, "zoom": 0.5},
"objects": [],
"event_rules": [],
}
var migrated: Dictionary = STAGE_SCENE_IO._migrate_to_current(legacy)
var expected_sky: String = "sky_sunset" if version in ["1.5", "1.6"] else "sky_neutral"
_expect(String(migrated.get("version", "")) == "1.7", "%s scene migrates to v1.7" % version)
_expect(String(migrated.get("sky_id", "")) == expected_sky, "%s migration preserves the compatible Sky choice" % version)
_expect(String(migrated.get("background_kind", "")) == "sky", "%s migration remains visually Sky-backed" % version)
_expect(String(migrated.get("plain_color", "")) == STAGE_SCENE_IO.DEFAULT_PLAIN_COLOR, "%s migration adds the default remembered color" % version)
_expect(bool(STAGE_SCENE_IO._validate_root(migrated).get("ok", false)), "%s migrated empty scene passes v1.7 root validation" % version)
var valid: Dictionary = _valid_document()
_expect(bool(STAGE_SCENE_IO._validate_root(valid).get("ok", false)), "valid v1.7 Plain Background fields pass validation")
var missing_kind: Dictionary = valid.duplicate(true)
missing_kind.erase("background_kind")
_expect(not bool(STAGE_SCENE_IO._validate_root(missing_kind).get("ok", false)), "v1.7 rejects a missing background kind")
var missing_sky: Dictionary = valid.duplicate(true)
missing_sky.erase("sky_id")
_expect(not bool(STAGE_SCENE_IO._validate_root(missing_sky).get("ok", false)), "v1.7 rejects a missing remembered Sky")
var missing_color: Dictionary = valid.duplicate(true)
missing_color.erase("plain_color")
_expect(not bool(STAGE_SCENE_IO._validate_root(missing_color).get("ok", false)), "v1.7 rejects a missing remembered Plain Background color")
var alpha_color: Dictionary = valid.duplicate(true)
alpha_color["plain_color"] = "#F5EFE0FF"
_expect(not bool(STAGE_SCENE_IO._validate_root(alpha_color).get("ok", false)), "v1.7 rejects alpha-bearing Plain Background colors")
var bad_color: Dictionary = valid.duplicate(true)
bad_color["plain_color"] = "F5EFE0"
_expect(not bool(STAGE_SCENE_IO._validate_root(bad_color).get("ok", false)), "v1.7 requires canonical hash-prefixed six-digit color")
func _test_live_backdrop_default() -> void:
var background: StageBackgroundView = _stage.get("_background_view") as StageBackgroundView
var sky_view: StageSkyView = _stage.get("_sky_view") as StageSkyView
var plain_fill: ColorRect = background.get_node("PlainFill") as ColorRect if background != null else null
_expect(background != null and sky_view != null and plain_fill != null, "live Stage owns the shared Sky and Plain renderer")
if background == null or sky_view == null or plain_fill == null:
return
_expect(background.get_background_kind() == &"sky" and sky_view.visible and not plain_fill.visible, "default live Stage shows Sky with Plain fill hidden")
_expect(background.get_plain_color().to_html(false).to_upper() == "F5EFE0", "default remembered Plain color is warm off-white")
var plain_starter: Dictionary = STAGE_SCENE_IO.read_file(PLAIN_STARTER_PATH).get("data", {}) as Dictionary
_expect(String(plain_starter.get("background_kind", "")) == "plain", "Plain Background starter selects a flat backdrop")
_expect(String(plain_starter.get("plain_color", "")) == "#F5EFE0" and (plain_starter.get("objects", []) as Array).is_empty(), "Plain Background starter is empty and uses the approved color")
func _test_plain_background_picker_flow() -> void:
var browser: StageAssetBrowser = _stage.get("_asset_browser") as StageAssetBrowser
_stage.call("_open_selector", "scenery")
var selector: AssetSelector = browser.get_selector()
selector.call("_set_gallery_tab", "backgrounds")
await process_frame
var grid: GridContainer = selector.find_child("GridContainer", true, false) as GridContainer
var plain_card: AssetCard = _find_card(grid, "plain_background")
_expect(selector.visible and plain_card != null, "real Scenery gallery shows the Plain Background card")
if plain_card == null:
return
await _activate_card(plain_card)
var title: Label = selector.find_child("TitleLabel", true, false) as Label
var controls: StageSurfaceColorControls = selector.find_child("PlainBackgroundColorControls", true, false) as StageSurfaceColorControls
_expect(String(_stage.get("_background_kind")) == "plain" and selector.visible, "Plain card immediately switches the Stage and keeps the gallery open")
_expect(title != null and title.text == "Choose background color", "Plain color choices use the approved heading")
_expect(controls != null and controls.get("_current_chip") != null, "color choices expose the current-color chip and swatch sections")
if controls == null:
return
await _save_visual_capture("phase19_plain_color_choices.png")
var recent_before: Array[String] = _stage.call("_surface_color_history_strings") as Array[String]
_expect(not recent_before.has("#F5EFE0"), "opening at the default does not add that color to recents")
var empty_message: Label = controls.find_child("RecentColorsEmptyLabel", true, false) as Label
if recent_before.is_empty():
_expect(empty_message != null and empty_message.text == "Colors you use will appear here.", "empty recent colors use the approved helper text")
var confirmed_color: Color = _stage.get("_plain_color") as Color
var confirmed_hex: String = _stage.call("_canonical_surface_color", confirmed_color) as String
var dirty_before: bool = bool(_stage.get("_dirty"))
var current_chip: Button = controls.get("_current_chip") as Button
await _activate_button(current_chip)
var picker_view: StageSurfaceColorPickerView = selector.get("_color_picker_view") as StageSurfaceColorPickerView
var picker: ColorPicker = picker_view.find_child("ColorPickerControl", true, false) as ColorPicker if picker_view != null else null
var use_button: Button = selector.get("_color_use_button") as Button
var back_button: Button = selector.get("_color_back_button") as Button
_expect(picker != null and use_button != null and back_button != null, "current-color chip opens the full custom picker with Back and Use color")
if picker == null or use_button == null or back_button == null:
return
var draft_color: Color = Color("#B34FD8")
_set_picker_draft(picker_view, picker, draft_color)
await process_frame
var background: StageBackgroundView = _stage.get("_background_view") as StageBackgroundView
var plain_fill: ColorRect = background.get_node("PlainFill") as ColorRect
var draft_snapshot: Dictionary = _stage.call("_collect_scene_data", false) as Dictionary
_expect(bool(_stage.get("_plain_color_draft_active")) and plain_fill.color.to_html(false).to_upper() == "B34FD8", "custom picker movement previews an opaque flat color on the Stage")
await _save_visual_capture("phase19_plain_picker_draft.png")
_expect(String(draft_snapshot.get("plain_color", "")) == confirmed_hex, "scene snapshots keep the confirmed color during a custom draft")
_expect(bool(_stage.get("_dirty")) == dirty_before and (_stage.call("_surface_color_history_strings") as Array[String]) == recent_before, "custom preview does not change dirty state or recents")
await _activate_button(back_button)
_expect(not bool(_stage.get("_plain_color_draft_active")) and plain_fill.color.to_html(false).to_upper() == confirmed_hex.trim_prefix("#"), "Back discards the draft and restores the confirmed Stage fill")
await _save_visual_capture("phase19_plain_picker_rollback.png")
_expect(bool(_stage.get("_dirty")) == dirty_before and (_stage.call("_surface_color_history_strings") as Array[String]) == recent_before, "Back leaves dirty state and recents unchanged")
_expect(selector.visible and title.text == "Choose background color", "Back returns to color choices with the scene picker still open")
await _activate_button(controls.get("_current_chip") as Button)
picker_view = selector.get("_color_picker_view") as StageSurfaceColorPickerView
picker = picker_view.find_child("ColorPickerControl", true, false) as ColorPicker if picker_view != null else null
_set_picker_draft(picker_view, picker, Color("#26A8D6"))
await _press_escape()
_expect(not bool(_stage.get("_plain_color_draft_active")) and plain_fill.color.to_html(false).to_upper() == confirmed_hex.trim_prefix("#"), "Escape from the custom picker restores the prior fill")
_expect(selector.visible and title.text == "Choose background color", "Escape returns to color choices instead of closing the Stage chooser")
await _activate_button(controls.get("_current_chip") as Button)
picker_view = selector.get("_color_picker_view") as StageSurfaceColorPickerView
picker = picker_view.find_child("ColorPickerControl", true, false) as ColorPicker if picker_view != null else null
_set_picker_draft(picker_view, picker, draft_color)
await _activate_button(selector.get("_color_use_button") as Button)
var committed_hex: String = _stage.call("_canonical_surface_color", _stage.get("_plain_color")) as String
var recent_after_commit: Array[String] = _stage.call("_surface_color_history_strings") as Array[String]
_expect(committed_hex == "#B34FD8" and plain_fill.color.to_html(false).to_upper() == "B34FD8", "Use color confirms the custom color on the Stage")
_expect(bool(_stage.get("_dirty")) and recent_after_commit.count(committed_hex) == 1 and recent_after_commit[0] == committed_hex, "one confirmation marks changed scene dirty and records the color once")
_expect(selector.visible and title.text == "Choose background color", "Use color returns to the choices view")
var path: String = "user://phase19_plain_background_roundtrip.scene"
var saved: bool = _stage.call("_save_scene_to_path", path, false) as bool
var read: Dictionary = STAGE_SCENE_IO.read_file(path)
var saved_data: Dictionary = read.get("data", {}) as Dictionary
_expect(saved and bool(read.get("ok", false)) and String(saved_data.get("background_kind", "")) == "plain" and String(saved_data.get("plain_color", "")) == committed_hex, "production save/reopen boundary stores the confirmed Plain color")
_stage.call("_close_selector")
_stage.call("_open_selector", "scenery")
selector = browser.get_selector()
selector.call("_set_gallery_tab", "backgrounds")
await process_frame
grid = selector.find_child("GridContainer", true, false) as GridContainer
var sky_card: AssetCard = _find_card(grid, "sky_clear_day")
if sky_card != null:
await _activate_card(sky_card)
_expect(String(_stage.get("_background_kind")) == "sky" and _stage.call("_canonical_surface_color", _stage.get("_plain_color")) == committed_hex, "switching to Sky retains the remembered Plain color")
var sky_saved: Dictionary = _stage.call("_collect_scene_data", false) as Dictionary
_expect(String(sky_saved.get("background_kind", "")) == "sky" and String(sky_saved.get("plain_color", "")) == committed_hex, "Sky-active scene snapshot preserves the remembered Plain color")
grid = selector.find_child("GridContainer", true, false) as GridContainer
var return_plain_card: AssetCard = _find_card(grid, "plain_background")
if return_plain_card != null:
await _activate_card(return_plain_card)
_expect(String(_stage.get("_background_kind")) == "plain" and _stage.call("_canonical_surface_color", _stage.get("_plain_color")) == committed_hex, "returning from Sky restores the confirmed Plain color")
controls = selector.find_child("PlainBackgroundColorControls", true, false) as StageSurfaceColorControls
var preset_swatches: ColorSwatchSelector = controls.get("_preset_swatches") as ColorSwatchSelector if controls != null else null
var preset_button: Button = preset_swatches.get_child(0) as Button if preset_swatches != null and preset_swatches.get_child_count() > 0 else null
var preset_color: Color = Color.WHITE
if preset_button != null:
preset_color = preset_button.get_meta("surface_color", Color.WHITE)
if preset_button != null:
await _activate_button(preset_button)
var preset_hex: String = _stage.call("_canonical_surface_color", preset_color) as String
var preset_recents: Array[String] = _stage.call("_surface_color_history_strings") as Array[String]
_expect(preset_button != null and preset_button.button_pressed and preset_button.text == "✓", "preset swatch selection displays its selected check")
_expect(_stage.call("_canonical_surface_color", _stage.get("_plain_color")) == preset_hex and preset_recents[0] == preset_hex, "preset swatch immediately confirms the Stage color and moves it to recent colors")
await _save_visual_capture("phase19_plain_preset_selected.png")
_stage.call("_close_selector")
var loaded: bool = _stage.call("_load_scene_from_path", path, false) as bool
_expect(loaded and String(_stage.get("_background_kind")) == "plain" and _stage.call("_canonical_surface_color", _stage.get("_plain_color")) == committed_hex, "production Stage load restores the confirmed Plain background")
if FileAccess.file_exists(path):
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
func _test_draft_cancel_on_mode_switch() -> void:
var browser: StageAssetBrowser = _stage.get("_asset_browser") as StageAssetBrowser
_stage.call("_open_selector", "scenery")
var selector: AssetSelector = browser.get_selector()
selector.call("_set_gallery_tab", "backgrounds")
await process_frame
var grid: GridContainer = selector.find_child("GridContainer", true, false) as GridContainer
var plain_card: AssetCard = _find_card(grid, "plain_background")
if plain_card != null:
await _activate_card(plain_card)
var controls: StageSurfaceColorControls = selector.find_child("PlainBackgroundColorControls", true, false) as StageSurfaceColorControls
await _activate_button(controls.get("_current_chip") as Button)
var picker_view: StageSurfaceColorPickerView = selector.get("_color_picker_view") as StageSurfaceColorPickerView
var picker: ColorPicker = picker_view.find_child("ColorPickerControl", true, false) as ColorPicker if picker_view != null else null
_set_picker_draft(picker_view, picker, Color("#E66A21"))
await process_frame
var confirmed_hex: String = _stage.call("_canonical_surface_color", _stage.get("_plain_color")) as String
_stage.call("set_mode", SandboxStage.StageMode.DIRECT)
await process_frame
var background: StageBackgroundView = _stage.get("_background_view") as StageBackgroundView
var fill: ColorRect = background.get_node("PlainFill") as ColorRect
_expect(not bool(_stage.get("_plain_color_draft_active")) and not selector.visible, "mode switch closes an active custom picker and cancels its draft")
_expect(fill.color.to_html(false).to_upper() == confirmed_hex.trim_prefix("#"), "mode-switch cancel restores the confirmed backdrop")
_stage.call("set_mode", SandboxStage.StageMode.EDIT)
await process_frame
func _test_draft_cancel_on_popup_hide() -> void:
var browser: StageAssetBrowser = _stage.get("_asset_browser") as StageAssetBrowser
_stage.call("_open_selector", "scenery")
var selector: AssetSelector = browser.get_selector()
selector.call("_set_gallery_tab", "backgrounds")
await process_frame
var grid: GridContainer = selector.find_child("GridContainer", true, false) as GridContainer
var plain_card: AssetCard = _find_card(grid, "plain_background")
if plain_card != null:
await _activate_card(plain_card)
var controls: StageSurfaceColorControls = selector.find_child("PlainBackgroundColorControls", true, false) as StageSurfaceColorControls
await _activate_button(controls.get("_current_chip") as Button)
var picker_view: StageSurfaceColorPickerView = selector.get("_color_picker_view") as StageSurfaceColorPickerView
var picker: ColorPicker = picker_view.find_child("ColorPickerControl", true, false) as ColorPicker if picker_view != null else null
_set_picker_draft(picker_view, picker, Color("#AC5E31"))
var confirmed_hex: String = _stage.call("_canonical_surface_color", _stage.get("_plain_color")) as String
selector.hide()
await process_frame
await process_frame
var background: StageBackgroundView = _stage.get("_background_view") as StageBackgroundView
var fill: ColorRect = background.get_node("PlainFill") as ColorRect
_expect(not bool(_stage.get("_plain_color_draft_active")), "unexpected popup dismissal cancels the custom-color draft")
_expect(fill.color.to_html(false).to_upper() == confirmed_hex.trim_prefix("#") and selector.visible, "popup dismissal restores the confirmed fill and keeps the chooser available")
browser.close()
await process_frame
func _test_draft_cancel_on_scene_replacement(starter_data: Dictionary) -> void:
var browser: StageAssetBrowser = _stage.get("_asset_browser") as StageAssetBrowser
_stage.call("_open_selector", "scenery")
var selector: AssetSelector = browser.get_selector()
selector.call("_set_gallery_tab", "backgrounds")
await process_frame
var grid: GridContainer = selector.find_child("GridContainer", true, false) as GridContainer
var plain_card: AssetCard = _find_card(grid, "plain_background")
if plain_card != null:
await _activate_card(plain_card)
var controls: StageSurfaceColorControls = selector.find_child("PlainBackgroundColorControls", true, false) as StageSurfaceColorControls
await _activate_button(controls.get("_current_chip") as Button)
var picker_view: StageSurfaceColorPickerView = selector.get("_color_picker_view") as StageSurfaceColorPickerView
var picker: ColorPicker = picker_view.find_child("ColorPickerControl", true, false) as ColorPicker if picker_view != null else null
_set_picker_draft(picker_view, picker, Color("#46A45F"))
await process_frame
var replaced: bool = _stage.call("_apply_scene_data", starter_data, "", false) as bool
var background: StageBackgroundView = _stage.get("_background_view") as StageBackgroundView
var fill: ColorRect = background.get_node("PlainFill") as ColorRect
_expect(replaced and not bool(_stage.get("_plain_color_draft_active")), "scene replacement applies after canceling the custom-color draft")
_expect(not selector.visible and String(_stage.get("_background_kind")) == "plain", "scene replacement closes the old selector and uses the new Plain starter")
_expect(fill.color.to_html(false).to_upper() == "F5EFE0", "replacement renders the new scene's confirmed starter color")
await _save_visual_capture("phase19_plain_offwhite_stage.png")
_stage.call("_commit_plain_color", Color("#262B36"))
await _save_visual_capture("phase19_plain_dark_stage.png")
_stage.call("set_mode", SandboxStage.StageMode.DIRECT)
await process_frame
await _save_visual_capture("phase19_plain_direct_mode.png")
_stage.call("set_mode", SandboxStage.StageMode.PLAY)
await process_frame
await _save_visual_capture("phase19_plain_play_mode.png")
var camera: Camera2D = _stage.get("_camera") as Camera2D
_stage.call("set_mode", SandboxStage.StageMode.EDIT)
_stage.set("_cli_startup", true)
var hovered_control: Control = root.gui_get_hovered_control()
var saved_mouse_filter: Control.MouseFilter = hovered_control.mouse_filter if hovered_control != null else Control.MOUSE_FILTER_STOP
if hovered_control != null:
hovered_control.mouse_filter = Control.MOUSE_FILTER_IGNORE
await process_frame
camera.global_position = Vector2(0.0, -400.0)
camera.zoom = Vector2.ONE * 0.5
var wheel: InputEventMouseButton = InputEventMouseButton.new()
wheel.button_index = MOUSE_BUTTON_WHEEL_UP
wheel.pressed = true
wheel.position = Vector2(root.size) * 0.5
_stage.call("_input", wheel)
var pan_press: InputEventMouseButton = InputEventMouseButton.new()
pan_press.button_index = MOUSE_BUTTON_MIDDLE
pan_press.pressed = true
pan_press.position = wheel.position
_stage.call("_input", pan_press)
var pan_motion: InputEventMouseMotion = InputEventMouseMotion.new()
pan_motion.position = pan_press.position + Vector2(80.0, -30.0)
pan_motion.relative = Vector2(80.0, -30.0)
_stage.call("_input", pan_motion)
var pan_release: InputEventMouseButton = InputEventMouseButton.new()
pan_release.button_index = MOUSE_BUTTON_MIDDLE
pan_release.position = pan_motion.position
_stage.call("_input", pan_release)
await process_frame
_expect(camera.zoom.x > 0.5 and not camera.global_position.is_equal_approx(Vector2(0.0, -400.0)), "plain backdrop remains visible through production zoom and pan input")
_stage.set("_cli_startup", false)
if hovered_control != null and is_instance_valid(hovered_control):
hovered_control.mouse_filter = saved_mouse_filter
await _save_visual_capture("phase19_plain_dark_pan_zoom.png")
root.size = Vector2i(640, 480)
await process_frame
await process_frame
await _save_visual_capture("phase19_plain_dark_narrow_viewport.png")
browser = _stage.get("_asset_browser") as StageAssetBrowser
_stage.call("_open_selector", "scenery")
selector = browser.get_selector()
selector.call("_set_gallery_tab", "backgrounds")
await process_frame
grid = selector.find_child("GridContainer", true, false) as GridContainer
plain_card = _find_card(grid, "plain_background")
if plain_card != null:
await _activate_card(plain_card)
await process_frame
var selector_rect: Rect2 = Rect2(Vector2(selector.position), Vector2(selector.size))
var narrow_size: Vector2 = Vector2(root.size)
_expect(selector.visible and selector_rect.position.x >= 0.0 and selector_rect.position.y >= 0.0 and selector_rect.end.x <= narrow_size.x and selector_rect.end.y <= narrow_size.y, "Plain color choices stay inside a narrow viewport")
await _save_visual_capture("phase19_plain_narrow_choices.png")
browser.close()
root.size = Vector2i(1280, 720)
await process_frame
func _test_recent_color_history_limit() -> void:
for index: int in range(9):
_stage.call("_record_recent_surface_color", Color.from_hsv(float(index) / 9.0, 0.8, 0.9))
var recent: Array[String] = _stage.call("_surface_color_history_strings") as Array[String]
_expect(recent.size() == 8, "recent surface color history is capped at eight colors")
var newest: String = _stage.call("_canonical_surface_color", Color.from_hsv(8.0 / 9.0, 0.8, 0.9)) as String
_expect(not recent.is_empty() and recent[0] == newest, "recent surface color history is most-recent-first")
func _valid_document() -> Dictionary:
return {
"version": "1.7",
"scene_name": "Validation fixture",
"sky_id": "sky_neutral",
"background_kind": "plain",
"plain_color": "#F5EFE0",
"camera": {"position": {"x": 0.0, "y": -400.0}, "zoom": 0.5},
"objects": [],
"event_rules": [],
}
func _find_card(grid: GridContainer, entry_id: String) -> AssetCard:
if grid == null:
return null
for child: Node in grid.get_children():
var card: AssetCard = child as AssetCard
if card != null and String(card.get_meta("entry_id", "")) == entry_id:
return card
return null
func _activate_card(card: AssetCard) -> void:
card.activated.emit(card.payload())
await process_frame
func _activate_button(button: Button) -> void:
if button == null:
_expect(false, "expected production button exists")
return
button.pressed.emit()
await process_frame
func _press_escape() -> void:
var viewport: Viewport = root
var press := InputEventKey.new()
press.keycode = KEY_ESCAPE
press.pressed = true
viewport.push_input(press)
await process_frame
var release := InputEventKey.new()
release.keycode = KEY_ESCAPE
release.pressed = false
viewport.push_input(release)
await process_frame
func _set_picker_draft(view: StageSurfaceColorPickerView, picker: ColorPicker, color: Color) -> void:
picker.color = color
view.call("_on_picker_color_changed", color)
await process_frame
func _save_visual_capture(file_name: String) -> void:
if DisplayServer.get_name() == "headless":
return
await RenderingServer.frame_post_draw
var capture: Image = root.get_texture().get_image()
var capture_dir: String = ProjectSettings.globalize_path("res://.phase19_captures")
DirAccess.make_dir_recursive_absolute(capture_dir)
var error: Error = capture.save_png(capture_dir.path_join(file_name))
_expect(error == OK, "rendered capture saved: %s" % file_name)
@@ -0,0 +1 @@
uid://iaplw44v1huj
+9 -8
View File
@@ -12,6 +12,7 @@ const STARTER_CARD_PREVIEW: Script = preload("res://scripts/stage/scenery/stage_
const STAGE_SKY_VIEW_SCRIPT: Script = preload("res://scripts/stage/scenery/stage_sky_view.gd") const STAGE_SKY_VIEW_SCRIPT: Script = preload("res://scripts/stage/scenery/stage_sky_view.gd")
const STARTER_PATHS: Array[String] = [ const STARTER_PATHS: Array[String] = [
"res://content/stages/starters/blank.scene", "res://content/stages/starters/blank.scene",
"res://content/stages/starters/plain_background.scene",
"res://content/stages/starters/town_street.scene", "res://content/stages/starters/town_street.scene",
"res://content/stages/starters/living_room.scene", "res://content/stages/starters/living_room.scene",
] ]
@@ -90,7 +91,7 @@ func _run() -> void:
) )
var browser: StageAssetBrowser = _stage.get("_asset_browser") as StageAssetBrowser var browser: StageAssetBrowser = _stage.get("_asset_browser") as StageAssetBrowser
var starter_entries: Array[Dictionary] = browser.scan_entries("starters") var starter_entries: Array[Dictionary] = browser.scan_entries("starters")
_expect(starter_entries.size() == 3, "New Scene gallery lists Blank, Town Street, and Living Room") _expect(starter_entries.size() == 4, "New Scene gallery lists Plain Background, Open Sky, Town Street, and Living Room")
var original_name: String = String(_stage.get("_scene_name")) var original_name: String = String(_stage.get("_scene_name"))
var original_world_count: int = (_stage.get_node("World") as Node2D).get_child_count() var original_world_count: int = (_stage.get_node("World") as Node2D).get_child_count()
var original_sky: String = String(_stage.get("_sky_id")) var original_sky: String = String(_stage.get("_sky_id"))
@@ -107,7 +108,7 @@ func _run() -> void:
selector = browser.get_selector() selector = browser.get_selector()
var starter_grid: GridContainer = selector.find_child("GridContainer", true, false) as GridContainer var starter_grid: GridContainer = selector.find_child("GridContainer", true, false) as GridContainer
await _test_starter_card_previews(starter_grid) await _test_starter_card_previews(starter_grid)
var town_card: AssetCard = starter_grid.get_child(1) as AssetCard if starter_grid != null and starter_grid.get_child_count() > 1 else null var town_card: AssetCard = _find_card_by_id(starter_grid, "starter_town_street")
_expect(town_card != null, "Town Street is selectable as a real starter card") _expect(town_card != null, "Town Street is selectable as a real starter card")
if town_card != null: if town_card != null:
await _activate_card(town_card) await _activate_card(town_card)
@@ -212,16 +213,16 @@ func _run() -> void:
for preview_node: Node in card_content.get_children(): for preview_node: Node in card_content.get_children():
if preview_node.get_script() == BACKGROUND_CARD_PREVIEW: if preview_node.get_script() == BACKGROUND_CARD_PREVIEW:
background_preview_count += 1 background_preview_count += 1
_expect(background_grid != null and background_grid.get_child_count() == 6 and background_preview_count == 6, "four Sky looks and both surface setup cards render production-style previews") _expect(background_grid != null and background_grid.get_child_count() == 7 and background_preview_count == 7, "Plain Background, four Sky looks, and both surface setup cards render production-style previews")
var cloudy_status: Label = cloudy_card.find_child("StatusLabel", true, false) as Label if cloudy_card != null else null var cloudy_status: Label = cloudy_card.find_child("StatusLabel", true, false) as Label if cloudy_card != null else null
_expect(cloudy_card != null and cloudy_card.button_pressed and cloudy_status != null and cloudy_status.text == "Current Sky", "gallery marks the loaded Town Street Sky as Current Sky") _expect(cloudy_card != null and cloudy_card.button_pressed and cloudy_status != null and cloudy_status.text == "Current background", "gallery marks the loaded Town Street Sky as the current background")
var clear_sky_card: AssetCard = _find_card_by_id(background_grid, "sky_clear_day") var clear_sky_card: AssetCard = _find_card_by_id(background_grid, "sky_clear_day")
if clear_sky_card != null: if clear_sky_card != null:
await _activate_card(clear_sky_card) await _activate_card(clear_sky_card)
var selected_clear_card: AssetCard = _find_card_by_id(selector.find_child("GridContainer", true, false) as GridContainer, "sky_clear_day") var selected_clear_card: AssetCard = _find_card_by_id(selector.find_child("GridContainer", true, false) as GridContainer, "sky_clear_day")
var clear_status: Label = selected_clear_card.find_child("StatusLabel", true, false) as Label if selected_clear_card != null else null var clear_status: Label = selected_clear_card.find_child("StatusLabel", true, false) as Label if selected_clear_card != null else null
_expect(selector.visible and String(_stage.get("_sky_id")) == "sky_clear_day", "choosing a Sky updates the Stage and keeps the chooser open") _expect(selector.visible and String(_stage.get("_sky_id")) == "sky_clear_day", "choosing a Sky updates the Stage and keeps the chooser open")
_expect(selected_clear_card != null and selected_clear_card.button_pressed and clear_status != null and clear_status.text == "Current Sky", "Current Sky marker follows the newly chosen card") _expect(selected_clear_card != null and selected_clear_card.button_pressed and clear_status != null and clear_status.text == "Current background", "current background marker follows the newly chosen card")
selector.call("_set_gallery_tab", "artwork") selector.call("_set_gallery_tab", "artwork")
await process_frame await process_frame
var artwork_entries: Array[Dictionary] = browser.scan_entries("scenery") var artwork_entries: Array[Dictionary] = browser.scan_entries("scenery")
@@ -614,7 +615,7 @@ func _test_starter_card_previews(starter_grid: GridContainer) -> void:
for card_node: Node in starter_grid.get_children(): for card_node: Node in starter_grid.get_children():
if not card_node.is_queued_for_deletion(): if not card_node.is_queued_for_deletion():
live_card_count += 1 live_card_count += 1
_expect(live_card_count == 3, "starter chooser has three scene cards to preview") _expect(live_card_count == 4, "starter chooser has four scene cards to preview")
var preview_count: int = 0 var preview_count: int = 0
var populated_scene_count: int = 0 var populated_scene_count: int = 0
for card_node: Node in starter_grid.get_children(): for card_node: Node in starter_grid.get_children():
@@ -628,8 +629,8 @@ func _test_starter_card_previews(starter_grid: GridContainer) -> void:
if int(preview.call("get_loaded_object_count")) > 0: if int(preview.call("get_loaded_object_count")) > 0:
populated_scene_count += 1 populated_scene_count += 1
var viewport: SubViewport = preview.get_child(0) as SubViewport if preview.get_child_count() > 0 else null var viewport: SubViewport = preview.get_child(0) as SubViewport if preview.get_child_count() > 0 else null
_expect(viewport != null and preview.find_child("SkyView", true, false) != null, "starter preview has an isolated viewport and sky renderer") _expect(viewport != null and preview.find_child("StageSkyView", true, false) != null, "starter preview has an isolated viewport and shared backdrop renderer")
_expect(preview_count == 3, "all three starter cards use scene previews instead of placeholder tiles") _expect(preview_count == 4, "all four starter cards use scene previews instead of placeholder tiles")
_expect(populated_scene_count == 2, "Town Street and Living Room previews load their scene objects") _expect(populated_scene_count == 2, "Town Street and Living Room previews load their scene objects")
@@ -0,0 +1,144 @@
extends SceneTree
const SELECTOR_SCENE: PackedScene = preload("res://scenes/stage/asset_selector.tscn")
const SANDBOX_THEME_SCRIPT: Script = preload("res://scripts/stage/sandbox_theme.gd")
var _checks: int = 0
var _failures: int = 0
var _selector: AssetSelector
func _initialize() -> void:
call_deferred("_run")
func _run() -> void:
root.size = Vector2i(1280, 720)
_selector = SELECTOR_SCENE.instantiate() as AssetSelector
root.add_child(_selector)
await process_frame
var stage_theme: SandboxTheme = SANDBOX_THEME_SCRIPT.new() as SandboxTheme
stage_theme.load_from("res://sandbox_theme.json")
_selector.apply_theme(stage_theme)
_selector.open("starters", _starter_entries())
await process_frame
await process_frame
_test_roomy_layout()
await _save_capture("phase19_starter_chooser_wide.png")
await _test_hover_style_and_capture()
await _test_narrow_layout()
_selector.hide()
_selector.queue_free()
await process_frame
if _failures == 0:
print("RESULT: ALL PASSED (%d checks)" % _checks)
quit(0)
else:
print("RESULT: %d FAILURE(S) out of %d checks" % [_failures, _checks])
quit(1)
func _starter_entries() -> Array[Dictionary]:
return [
{
"id": "starter_plain_background",
"name": "Plain Background",
"description": "An empty stage with one color. Choose a new color whenever you like.",
"path": "res://content/stages/starters/plain_background.scene",
},
{
"id": "starter_blank_scene",
"name": "Open Sky",
"description": "An empty stage with a soft sky. Sun and clouds, ready for your story.",
"path": "res://content/stages/starters/blank.scene",
},
{
"id": "starter_town_street",
"name": "Town Street",
"description": "Cloudy sky, shops, trees, sidewalk, and road.",
"path": "res://content/stages/starters/town_street.scene",
},
{
"id": "starter_living_room",
"name": "Living Room",
"description": "A cozy room with a window, rug, and furniture.",
"path": "res://content/stages/starters/living_room.scene",
},
]
func _test_roomy_layout() -> void:
var grid: GridContainer = _grid()
var close_button: Button = _selector.find_child("CloseButton", true, false) as Button
_expect(_selector.size.x == 1160, "roomy starter chooser uses the preferred 1160-pixel width")
_expect(int(_selector.get("_active_columns")) == 2 and grid != null and grid.columns == 2, "roomy chooser presents two card columns")
_expect(close_button != null and close_button.visible and close_button.custom_minimum_size.y >= 44.0, "roomy chooser keeps its visible Close action reachable")
var first_card: Control = grid.get_child(0) as Control if grid != null and grid.get_child_count() > 0 else null
var preview: Control = first_card.find_child("StarterScenePreview", true, false) as Control if first_card != null else null
var viewport: SubViewport = preview.get_child(0) as SubViewport if preview != null and preview.get_child_count() > 0 else null
var preview_aspect: float = float(viewport.size.x) / float(viewport.size.y) if viewport != null and viewport.size.y > 0 else 0.0
_expect(first_card != null and first_card.custom_minimum_size.x >= 500.0, "roomy starter cards expand to at least 500 pixels")
_expect(preview != null and preview.custom_minimum_size.x >= 500.0 and preview.custom_minimum_size.y >= 240.0, "roomy previews meet the approved dimensions")
_expect(viewport != null and viewport.size.x >= 500 and viewport.size.y >= 240 and preview_aspect >= 1.9 and preview_aspect <= 2.2, "preview render target preserves the wide scene shape")
var title: Label = _selector.find_child("TitleLabel", true, false) as Label
_expect(title != null and title.visible and title.text == "Choose a starter scene", "roomy chooser keeps its readable title")
func _test_narrow_layout() -> void:
root.size = Vector2i(550, 690)
await process_frame
_selector.call("_update_popup_layout")
_selector.call("_rebuild")
await process_frame
await process_frame
var grid: GridContainer = _grid()
var close_button: Button = _selector.find_child("CloseButton", true, false) as Button
_expect(_selector.size.x <= root.size.x - 24, "narrow chooser stays within the safe screen margins")
_expect(int(_selector.get("_active_columns")) == 1 and grid != null and grid.columns == 1, "narrow chooser switches to a single card column")
_expect(int(_selector.get("_page_capacity")) == 4 and grid != null and grid.get_child_count() == 4, "narrow chooser keeps all four cards in the scrollable body")
_expect(close_button != null and close_button.visible, "narrow chooser keeps Close visible outside the scrolling body")
var first_card: Control = grid.get_child(0) as Control if grid != null and grid.get_child_count() > 0 else null
var preview: Control = first_card.find_child("StarterScenePreview", true, false) as Control if first_card != null else null
_expect(preview != null and preview.custom_minimum_size.x >= 400.0 and preview.custom_minimum_size.y >= 200.0, "narrow single-column layout retains large previews")
await _save_capture("phase19_starter_chooser_narrow.png")
func _test_hover_style_and_capture() -> void:
var grid: GridContainer = _grid()
var hover_card: Button = grid.get_child(1) as Button if grid != null and grid.get_child_count() > 1 else null
if hover_card == null:
_expect(false, "starter card is available for hover preview")
return
var hover_style: StyleBoxFlat = hover_card.get_theme_stylebox("hover") as StyleBoxFlat
_expect(hover_style != null and hover_style.border_color.is_equal_approx(Color("#22C6FF")), "starter hover style uses the EDIT blue border")
if hover_style == null:
return
var normal_style: StyleBox = hover_card.get_theme_stylebox("normal")
hover_card.add_theme_stylebox_override("normal", hover_style)
await process_frame
await _save_capture("phase19_starter_chooser_hover.png")
hover_card.add_theme_stylebox_override("normal", normal_style)
func _grid() -> GridContainer:
return _selector.find_child("GridContainer", true, false) as GridContainer
func _expect(condition: bool, message: String) -> void:
_checks += 1
if condition:
print("PASS: " + message)
else:
_failures += 1
push_error("Starter chooser layout check failed: " + message)
func _save_capture(file_name: String) -> void:
if DisplayServer.get_name() == "headless":
return
await RenderingServer.frame_post_draw
var capture: Image = root.get_texture().get_image()
var capture_dir: String = ProjectSettings.globalize_path("res://.phase19_captures")
DirAccess.make_dir_recursive_absolute(capture_dir)
var error: Error = capture.save_png(capture_dir.path_join(file_name))
_expect(error == OK, "capture saved for visual inspection: %s" % file_name)
@@ -0,0 +1 @@
uid://dp47aexhannrg
+3 -2
View File
@@ -58,8 +58,9 @@ func _test_v15_migration() -> void:
] ]
} }
var migrated: Dictionary = STAGE_SCENE_IO._migrate_to_current(source) var migrated: Dictionary = STAGE_SCENE_IO._migrate_to_current(source)
_expect(String(migrated.get("version", "")) == "1.6", "v1.5 scenes migrate to v1.6") _expect(String(migrated.get("version", "")) == "1.7", "v1.5 scenes migrate to v1.7")
_expect(String(migrated.get("sky_id", "")) == "sky_cloudy_day", "v1.5 migration preserves the saved Sky") _expect(String(migrated.get("sky_id", "")) == "sky_cloudy_day", "v1.5 migration preserves the saved Sky")
_expect(String(migrated.get("background_kind", "")) == "sky" and String(migrated.get("plain_color", "")) == STAGE_SCENE_IO.DEFAULT_PLAIN_COLOR, "v1.5 migration adds the remembered Plain Background defaults")
var objects: Array = migrated.get("objects", []) as Array var objects: Array = migrated.get("objects", []) as Array
_expect(String((objects[0] as Dictionary).get("finish_id", "")) == "finish_ground_sidewalk", "v1.5 migration preserves walkable terrain finishes") _expect(String((objects[0] as Dictionary).get("finish_id", "")) == "finish_ground_sidewalk", "v1.5 migration preserves walkable terrain finishes")
var migrated_brick_color: String = String((objects[1] as Dictionary).get("color", "")).to_upper() var migrated_brick_color: String = String((objects[1] as Dictionary).get("color", "")).to_upper()
@@ -157,7 +158,7 @@ func _test_background_ground_model_and_serialization(world: Node2D, surface: Sta
_expect(selection.hit_test(surface.global_position) == surface, "Edit Scenery hit-testing can select background ground") _expect(selection.hit_test(surface.global_position) == surface, "Edit Scenery hit-testing can select background ground")
var data: Dictionary = _stage.call("_collect_scene_data", false) var data: Dictionary = _stage.call("_collect_scene_data", false)
var validation: Dictionary = STAGE_SCENE_IO._validate_root(data) var validation: Dictionary = STAGE_SCENE_IO._validate_root(data)
_expect(String(data.get("version", "")) == "1.6" and bool(validation.get("ok", false)), "background ground serializes and validates in the current scene schema") _expect(String(data.get("version", "")) == STAGE_SCENE_IO.FILE_VERSION and bool(validation.get("ok", false)), "background ground serializes and validates in the current scene schema")
var found: Dictionary = {} var found: Dictionary = {}
for entry_value: Variant in data.get("objects", []): for entry_value: Variant in data.get("objects", []):
if entry_value is Dictionary and String((entry_value as Dictionary).get("type", "")) == "background_ground": if entry_value is Dictionary and String((entry_value as Dictionary).get("type", "")) == "background_ground":