feat: Enhance surface setup chooser with compact mode and cancel functionality

This commit is contained in:
2026-10-19 09:46:51 -04:00
parent 26dd9c64e1
commit 80ba83b703
5 changed files with 158 additions and 24 deletions
+16 -2
View File
@@ -47,7 +47,8 @@ func build_ui(ui_layer: CanvasLayer, ui_font: Font, emoji_font: Font, sandbox_th
selector_dim = ColorRect.new()
selector_dim.name = "SelectorDim"
selector_dim.color = Color(0.0, 0.0, 0.0, SELECTOR_DIM_ALPHA)
selector_dim.mouse_filter = Control.MOUSE_FILTER_IGNORE
# Keep clicks outside the modal from reaching the Stage canvas beneath it.
selector_dim.mouse_filter = Control.MOUSE_FILTER_STOP
selector_dim.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
selector_dim.visible = false
ui_layer.add_child(selector_dim)
@@ -55,7 +56,7 @@ func build_ui(ui_layer: CanvasLayer, ui_font: Font, emoji_font: Font, sandbox_th
selector = ASSET_SELECTOR_SCENE.instantiate() as AssetSelector
selector.item_selected.connect(func(entry: Dictionary) -> void: asset_selected_requested.emit(entry))
selector.cancelled.connect(_on_selector_cancelled)
selector.popup_hide.connect(_on_selector_cancelled)
selector.popup_hide.connect(_on_selector_popup_hide)
selector.browse_requested.connect(show_browse_dialog)
selector.refresh_requested.connect(func() -> void: refresh_requested.emit())
selector.make_artwork_requested.connect(func() -> void: make_artwork_requested.emit())
@@ -281,6 +282,19 @@ func _on_selector_cancelled() -> void:
selector_cancel_requested.emit()
func _on_selector_popup_hide() -> void:
if not selector_open:
return
# PopupPanel can hide itself when it loses focus. Keep the chooser alive so an
# outside click cannot silently cancel the user's scenery setup.
call_deferred("_restore_selector_after_unexpected_hide")
func _restore_selector_after_unexpected_hide() -> void:
if selector_open and selector != null and not selector.visible:
selector.popup_centered()
func get_selector() -> AssetSelector:
return selector