Class PlaceableSelectionUI
- Namespace
- GridPlacement.GDScript
- Assembly
- MoonBark.GridPlacement.GDScript.dll
Unified UI component for selecting placeable objects and placeable sequences to build.\n\nProvides a tabbed, grid-based interface for selecting placeables and placeable sequences to place in the world. Supports folder-based asset loading with [PlacementAssetResolver] for automatic discovery of content and category tags. Integrates with [PlacementSystem] to initiate placement mode when items are selected.\n\n[b]Key Features:[/b] [ul] - Mixed content grids supporting both individual placeables and sequences - Configurable sizing for consistent template height and icon dimensions - Variant cycling for sequences through enhanced [PlaceableListEntry] components - Automatic asset loading from configured folders - Category-based organization with tabs [/ul]\n\n[b]Usage:[/b] [codeblock] var selection_ui = PlaceableSelectionUI.new() selection_ui.placeables_folder = "res://my_placeables" selection_ui.category_profiles_folder = "res://my_profiles" selection_ui.fixed_template_height = 48 selection_ui.fixed_icon_size = 40 [/codeblock]
class PlaceableSelectionUI extends PlacementControl
Properties
category_profiles_folder
Path to folder containing category tag resources.[br] Profiles found here are automatically loaded and added to [member category_profiles].
@export_dir var category_profiles_folder: String = ""
placeables_folder
Path to folder containing placeable resources.[br] Placeables found here are automatically loaded and added to [member placeables].
@export_dir var placeables_folder: String = ""
sequences_folder
Path to folder containing placeable sequence resources.[br] Sequences found here are automatically loaded and added to [member sequences].
@export_dir var sequences_folder: String = ""
category_profiles
Category tags to include alongside folder-loaded ones.[br] These profiles are combined with profiles loaded from [member category_profiles_folder].
@export var category_profiles: Array[PlacementProfile] = []
placeables
Individual placeables to include alongside folder-loaded ones.[br] These are displayed in grids alongside sequences. Combined with placeables from [member placeables_folder].
@export var placeables: Array[ScenePlacementEntry] = []
sequences
ScenePlacementEntry sequences to include alongside folder-loaded ones.[br] Sequences allow variant cycling within a single grid slot. Combined with sequences from [member sequences_folder].
@export var sequences: Array[PlaceableSequence] = []
grid_columns
Number of columns for the grid layout.[br] Default: 1 (single column list layout).
@export_range(1, 10, 1) var grid_columns: int = 1
placeable_entry_template
Template scene for individual placeable entries.[br] Should be a [PlaceableView] that displays icon and name.
@export var placeable_entry_template: PackedScene
sequence_entry_template
Template scene for sequence entries with variant cycling.[br] Should be a [PlaceableListEntry] that supports cycling through sequence variants.
@export var sequence_entry_template: PackedScene
fixed_template_height
Fixed height for all templates to prevent resizing when cycling through sequence variants.[br][br] When set to a positive value, enforces consistent height for all template entries.[br] When set to 0, disables PlaceableSelectionUI-level height enforcement and allows templates to size naturally.[br] Note: Individual PlaceableView instances may still enforce their own height via their fixed_view_height property.[br] Default: 48 pixels for consistent template sizing.
@export var fixed_template_height: int = 48
fixed_icon_size
Fixed icon size for all placeable view icons to ensure consistent icon dimensions.[br][br] When set to a positive value, enforces both width and height for all icon TextureRects in PlaceableView instances.[br] When set to 0, icon sizing is not enforced and will use template defaults.[br] Default: 40 pixels for standard icon sizing.
@export var fixed_icon_size: int = 40
show_category_tab_names
Whether category tab titles should be visible for manual category selection.[br] When false, tabs are hidden and only grid content is shown.
@export var show_category_tab_names: bool = true
hide_ui_on_selection
Whether to hide the selection UI when an item is selected.[br] When true, the UI automatically hides after the user selects a placeable or sequence.
@export var hide_ui_on_selection: bool = false
ui_root
Root control node for showing and hiding the entire UI.
@export var ui_root: Control
tab_container
Tab container that handles category-based organization.[br] Each tab represents a category tag and contains a grid of matching placeables/sequences.
@export var tab_container: TabContainer
folder_profiles
var folder_profiles = PlacementAssetResolver.load_profiles(category_profiles_folder, [])
folder_placeables
var folder_placeables = PlacementAssetResolver.load_placeables(placeables_folder, [])
folder_sequences
var folder_sequences = PlacementAssetResolver.load_placeable_sequences(sequences_folder, [])
actual_tab_index
var actual_tab_index: int = 0
profile
var profile = category_profiles[profile_index]
matched_placeables
var matched_placeables: Array[ScenePlacementEntry] = _get_placeables_with_profile(profile)
matched_sequences
var matched_sequences: Array[PlaceableSequence] = _get_sequences_with_profile(profile)
unified_grid
var unified_grid: GridContainer
matched
var matched: Array[PlaceableSequence] = []
matched
var matched: Array[PlaceableSequence] = []
sequence_matches
var sequence_matches = false
grid
var grid = GridContainer.new()
entry_node
var entry_node: Node = sequence_entry_template.instantiate()
entry
var entry: PlaceableListEntry = entry_node as PlaceableListEntry
entry_node
var entry_node: Node = sequence_entry_template.instantiate()
entry
var entry: PlaceableListEntry = entry_node as PlaceableListEntry
active_placeable
var active_placeable: ScenePlacementEntry = entry.get_active_placeable()
cat_item_list
var cat_item_list: ItemList = tab_container.get_child(i) as ItemList
cat_item_list
var cat_item_list: ItemList = tab_container.get_child(i) as ItemList
issues
var issues: Array[String] = []
has_placeables
var has_placeables = placeables.size() > 0
has_sequences
var has_sequences = sequences.size() > 0
at_least_one_category
var at_least_one_category = false
has_placeables
var has_placeables = placeables.size() > 0
has_sequences
var has_sequences = sequences.size() > 0
texture_rects
var texture_rects = _find_nodes_by_type(template_entry, "TextureRect")
tex_rect
var tex_rect = texture_rect as TextureRect
found_nodes
var found_nodes: Array[Node] = []
Methods
get_mode_state
func get_mode_state() -> ModeState:
Returns
resolve_placement_dependencies
func resolve_placement_dependencies(p_container : PlacementContainer) -> void:
Parameters
p_container
Returns
rebuild
func rebuild() -> void:
Returns
clear
func clear() -> void:
Returns
add_placeables
func add_placeables(new_placeables : Array[ScenePlacementEntry]) -> void:
Parameters
new_placeables
Returns
remove_placeables
func remove_placeables(rem_placeables : Array[ScenePlacementEntry]) -> void:
Parameters
rem_placeables
Returns
get_runtime_issues
func get_runtime_issues() -> Array[String]:
Returns
Events
valid_changed
Emitted when the UI validation state changes.[br] [param is_valid] True if the UI is properly configured and ready for use.
signal valid_changed(is_valid : bool)