Add visual harmonization tests for editor UI components and ground finish chooser
- Implemented `test_editor_visual_harmonization.gd` to validate the Stickman editor and prop editor UI layouts, ensuring proper functionality and visual consistency. - Created `test_editor_visual_theme.gd` to verify the loading and application of visual themes in the editor, including semantic overrides and default values. - Introduced `test_phase19_ground_finish_chooser.gd` to test the ground finish chooser's functionality, including layout responsiveness, selection behavior, and interaction with the stage. - Added new scripts for ground finish preview and chooser UI components to enhance the editor's visual representation of ground finishes.
This commit is contained in:
@@ -150,8 +150,13 @@ func open(
|
||||
entries: Array[Dictionary],
|
||||
current_sky_id: String = "",
|
||||
current_background_kind: String = "sky",
|
||||
plain_color: Color = Color("#F5EFE0")
|
||||
plain_color: Color = Color("#F5EFE0"),
|
||||
browse_state: Dictionary = {}
|
||||
) -> void:
|
||||
var restore_scenery_browse_state: bool = p_kind == "scenery" and not browse_state.is_empty()
|
||||
var restored_gallery_tab: String = String(browse_state.get("gallery_tab", "backgrounds")) if restore_scenery_browse_state else "backgrounds"
|
||||
var restored_filter_id: String = String(browse_state.get("tag_id", "all")) if restore_scenery_browse_state else "all"
|
||||
var restored_scroll: int = int(browse_state.get("scroll_vertical", 0)) if restore_scenery_browse_state else 0
|
||||
_cancel_plain_picker_preview(false)
|
||||
kind = p_kind
|
||||
_setup_kind = &""
|
||||
@@ -164,28 +169,62 @@ func open(
|
||||
_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 a 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()
|
||||
_tabs.visible = kind == "scenery"
|
||||
_filter_chips.visible = false
|
||||
_make_artwork_button.visible = false
|
||||
_edit_scenery_button.visible = false
|
||||
_browse_button.visible = kind == "stickman" or kind == "prop" or kind == "scenery"
|
||||
_refresh_button.visible = kind == "stickman" or kind == "prop" or kind == "scenery"
|
||||
_empty_label.text = "No scenery found. Choose Make artwork to draw a new piece." if kind == "scenery" else ("No props found. Browse for a .prop file." if kind == "prop" else ("No starter scenes are available." if kind == "starters" else "No stickmen found."))
|
||||
_gallery_tab = "backgrounds"
|
||||
_tag_id = "all"
|
||||
_backgrounds_tab.set_pressed_no_signal(true)
|
||||
_artwork_tab.set_pressed_no_signal(false)
|
||||
_browse_button.visible = false
|
||||
_refresh_button.visible = false
|
||||
_empty_label.text = "No scenery found. Choose Make artwork to draw a new piece." if kind == "scenery" else ("No props in the library yet." if kind == "prop" else ("No starter scenes are available." if kind == "starters" else "No stickmen in the library yet."))
|
||||
_gallery_tab = restored_gallery_tab
|
||||
_tag_id = restored_filter_id
|
||||
_backgrounds_tab.set_pressed_no_signal(_gallery_tab == "backgrounds")
|
||||
_artwork_tab.set_pressed_no_signal(_gallery_tab == "artwork")
|
||||
set_entries(entries)
|
||||
if kind == "scenery":
|
||||
_set_gallery_tab("backgrounds")
|
||||
_set_gallery_tab(_gallery_tab)
|
||||
popup_centered(size)
|
||||
call_deferred("_settle_popup_after_open")
|
||||
if restore_scenery_browse_state:
|
||||
call_deferred("_restore_browse_scroll_after_open", restored_scroll, restored_gallery_tab)
|
||||
|
||||
|
||||
func capture_browse_state() -> Dictionary:
|
||||
if kind != "scenery":
|
||||
return {}
|
||||
return {
|
||||
"gallery_tab": _gallery_tab,
|
||||
"tag_id": _tag_id,
|
||||
"scroll_vertical": _grid_scroll.scroll_vertical if _grid_scroll != null else 0,
|
||||
}
|
||||
|
||||
|
||||
func _restore_browse_scroll_after_open(scroll_vertical: int, gallery_tab: String) -> void:
|
||||
await get_tree().process_frame
|
||||
if not is_inside_tree() or not visible or kind != "scenery" or _gallery_tab != gallery_tab:
|
||||
return
|
||||
_grid_scroll.scroll_vertical = maxi(0, scroll_vertical)
|
||||
|
||||
|
||||
func _settle_popup_after_open() -> void:
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
if is_inside_tree() and visible:
|
||||
# PopupPanel can resize after the first native layout pass. Reapply the
|
||||
# content-sized width once child minimum sizes and DPI scaling have settled.
|
||||
var size_before_settle: Vector2i = size
|
||||
_update_popup_layout(true)
|
||||
if size != size_before_settle:
|
||||
popup_centered(size)
|
||||
|
||||
|
||||
func set_entries(entries: Array[Dictionary]) -> void:
|
||||
_entries = entries
|
||||
if _grid_scroll != null:
|
||||
_grid_scroll.scroll_vertical = 0
|
||||
if kind == "scenery":
|
||||
_rebuild_artwork_filter_chips()
|
||||
_thumbnails.clear()
|
||||
@@ -881,8 +920,8 @@ func _set_gallery_tab(tab: String) -> void:
|
||||
_filter_chips.visible = kind == "scenery" and tab == "artwork"
|
||||
_make_artwork_button.visible = kind == "scenery" and tab == "artwork"
|
||||
_edit_scenery_button.visible = kind == "scenery"
|
||||
_browse_button.visible = kind == "stickman" or kind == "prop"
|
||||
_refresh_button.visible = kind == "stickman" or kind == "prop"
|
||||
_browse_button.visible = false
|
||||
_refresh_button.visible = false
|
||||
_empty_label.text = "No artwork here yet." if tab == "artwork" else "Choose a Sky look or wall finish."
|
||||
_page = 0
|
||||
_update_popup_layout(true)
|
||||
@@ -953,6 +992,7 @@ func _update_popup_layout(keep_visible_position: bool = false) -> void:
|
||||
var in_subview: bool = in_setup or in_color_picker or in_plain_choices
|
||||
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 asset_scrolling_gallery: bool = _uses_scrolling_asset_gallery() and not in_subview
|
||||
var filtered: Array[Dictionary] = _filtered_entries()
|
||||
_tabs.visible = kind == "scenery" and not in_subview
|
||||
_filter_chips.visible = scenery_artwork_gallery
|
||||
@@ -972,17 +1012,17 @@ func _update_popup_layout(keep_visible_position: bool = false) -> void:
|
||||
_empty_label.visible = filtered.is_empty() and not in_subview
|
||||
_grid.visible = not filtered.is_empty() and not in_subview
|
||||
_grid_scroll.visible = not filtered.is_empty() or in_subview
|
||||
_footer.alignment = BoxContainer.ALIGNMENT_BEGIN if scenery_artwork_gallery or in_subview else BoxContainer.ALIGNMENT_CENTER
|
||||
_footer.alignment = BoxContainer.ALIGNMENT_BEGIN if scenery_artwork_gallery or asset_scrolling_gallery or in_subview else BoxContainer.ALIGNMENT_CENTER
|
||||
_footer.add_theme_constant_override(
|
||||
"separation",
|
||||
_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 width_ratio: float = 0.98 if in_subview else (0.96 if kind == "starters" else 0.94)
|
||||
var width_ratio: float = 0.98 if in_subview or asset_scrolling_gallery 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 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 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_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
|
||||
if kind == "starters":
|
||||
preferred_width = _theme_number("popups.asset_selector.starter_dialog_width", 1160.0, 440.0, 2400.0)
|
||||
@@ -993,14 +1033,14 @@ func _update_popup_layout(keep_visible_position: bool = false) -> void:
|
||||
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 minimum_card_width: float = CELL_MIN_SIZE.x
|
||||
var minimum_card_width: float = _cell_min_size.x
|
||||
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
|
||||
_page_capacity = maxi(1, filtered.size()) if scenery_background_gallery or scenery_artwork_gallery or asset_scrolling_gallery or kind == "starters" else _active_columns * ROWS
|
||||
_grid.columns = _active_columns
|
||||
var available_card_width: float = (grid_width - GRID_H_SEPARATION * (_active_columns - 1)) / float(_active_columns)
|
||||
var card_width: float = available_card_width if kind == "starters" else minf(CELL_MIN_SIZE.x, available_card_width)
|
||||
var card_width: float = available_card_width if kind == "starters" else minf(_cell_min_size.x, available_card_width)
|
||||
var card_height_limit: float = 248.0 if kind != "starters" else INF
|
||||
var card_height: float
|
||||
if kind == "starters":
|
||||
@@ -1128,6 +1168,7 @@ func _rebuild() -> void:
|
||||
var in_subview: bool = in_setup or in_color_picker or in_plain_choices
|
||||
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 asset_scrolling_gallery: bool = _uses_scrolling_asset_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
|
||||
@@ -1144,8 +1185,8 @@ func _rebuild() -> void:
|
||||
_color_use_button.visible = in_color_picker
|
||||
_edit_scenery_button.visible = kind == "scenery" and not in_subview
|
||||
_make_artwork_button.visible = scenery_artwork_gallery
|
||||
_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
|
||||
_browse_button.visible = false
|
||||
_refresh_button.visible = false
|
||||
_footer_spacer.visible = scenery_artwork_gallery
|
||||
_empty_label.visible = filtered.is_empty() and not in_subview
|
||||
_grid.visible = not filtered.is_empty() and not in_subview
|
||||
@@ -1255,6 +1296,10 @@ func _is_scenery_artwork_gallery() -> bool:
|
||||
return kind == "scenery" and _gallery_tab == "artwork"
|
||||
|
||||
|
||||
func _uses_scrolling_asset_gallery() -> bool:
|
||||
return kind == "prop" or kind == "stickman"
|
||||
|
||||
|
||||
func _count_scene_background_entries(entries: Array[Dictionary]) -> int:
|
||||
var count: int = 0
|
||||
for entry: Dictionary in entries:
|
||||
@@ -1324,7 +1369,7 @@ func _build_cell(entry: Dictionary, requested_size: Vector2 = Vector2.ZERO) -> C
|
||||
card_payload["status"] = "Current background"
|
||||
card_payload["status_color"] = _theme_color("mode_colors.edit", Color("#22C6FF"))
|
||||
cell.configure(card_payload, _thumbnails.get(key, null), null)
|
||||
if kind == "scenery" or kind == "starters":
|
||||
if kind == "scenery" or kind == "starters" or _uses_scrolling_asset_gallery():
|
||||
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_corner_radius: int = _theme_integer("popups.asset_selector.corner_radius", 16, 8, 32)
|
||||
@@ -1351,13 +1396,12 @@ func _build_cell(entry: Dictionary, requested_size: Vector2 = Vector2.ZERO) -> C
|
||||
card_hover_border_width,
|
||||
card_corner_radius
|
||||
))
|
||||
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
|
||||
))
|
||||
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),
|
||||
@@ -1447,7 +1491,7 @@ func _apply_chooser_visual_style() -> void:
|
||||
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)
|
||||
if _title_label != null:
|
||||
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)
|
||||
var title_size: int = _theme_integer("popups.asset_selector.starter_title_size", 30, 22, 48) if kind == "starters" else _theme_integer("popups.asset_selector.setup_title_size", 30, 22, 48)
|
||||
_title_label.add_theme_font_size_override("font_size", title_size)
|
||||
_title_label.add_theme_color_override("font_color", text_color)
|
||||
_apply_emphasis_font(_title_label)
|
||||
|
||||
Reference in New Issue
Block a user