Add new test file for phase 19 scenery with unique identifier
This commit is contained in:
@@ -10,7 +10,10 @@ var _dragging: bool = false
|
||||
var _drag_threshold: float = 8.0
|
||||
var _icon: TextureRect = null
|
||||
var _glyph: Label = null
|
||||
var _box: VBoxContainer = null
|
||||
var _label: Label = null
|
||||
var _description: Label = null
|
||||
var _status_label: Label = null
|
||||
|
||||
func configure(payload: Dictionary, icon_texture: Texture2D = null, theme: Variant = null) -> void:
|
||||
_payload = payload.duplicate(true)
|
||||
@@ -25,11 +28,55 @@ func configure(payload: Dictionary, icon_texture: Texture2D = null, theme: Varia
|
||||
focus_mode = Control.FOCUS_ALL
|
||||
tooltip_text = String(_payload.get("label", ""))
|
||||
for child: Node in get_children(): child.queue_free()
|
||||
var box := VBoxContainer.new(); box.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT); box.mouse_filter = Control.MOUSE_FILTER_IGNORE; box.clip_contents = true
|
||||
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)
|
||||
_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)
|
||||
_box = VBoxContainer.new(); _box.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT); _box.mouse_filter = Control.MOUSE_FILTER_IGNORE; _box.clip_contents = true
|
||||
_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)
|
||||
_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)
|
||||
var description: String = String(_payload.get("description", ""))
|
||||
var status: String = String(_payload.get("status", ""))
|
||||
if not status.is_empty():
|
||||
_status_label = Label.new()
|
||||
_status_label.name = "StatusLabel"
|
||||
_status_label.text = status
|
||||
_status_label.custom_minimum_size = Vector2(0.0, 22.0)
|
||||
_status_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_status_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
_status_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
_status_label.add_theme_font_size_override("font_size", 16)
|
||||
_status_label.add_theme_color_override("font_color", _payload.get("status_color", Color.WHITE))
|
||||
_status_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_box.add_child(_status_label)
|
||||
if not description.is_empty():
|
||||
_description = Label.new()
|
||||
_description.text = description
|
||||
_description.custom_minimum_size = Vector2(0.0, 34.0)
|
||||
_description.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_description.vertical_alignment = VERTICAL_ALIGNMENT_TOP
|
||||
_description.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
_description.max_lines_visible = 2
|
||||
_description.add_theme_font_size_override("font_size", 14)
|
||||
_description.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_box.add_child(_description)
|
||||
|
||||
|
||||
func set_preview_control(preview: Control) -> void:
|
||||
if preview == null or _box == null:
|
||||
return
|
||||
var preview_size: Vector2 = _icon.custom_minimum_size if _icon != null else Vector2(64.0, 64.0)
|
||||
if _icon != null and _icon.get_parent() == _box:
|
||||
_box.remove_child(_icon)
|
||||
_icon.queue_free()
|
||||
_icon = null
|
||||
if _glyph != null and _glyph.get_parent() == _box:
|
||||
_box.remove_child(_glyph)
|
||||
_glyph.queue_free()
|
||||
_glyph = null
|
||||
preview.custom_minimum_size = preview_size
|
||||
preview.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
preview.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_box.add_child(preview)
|
||||
_box.move_child(preview, 0)
|
||||
|
||||
func set_thumbnail(texture: Texture2D) -> void:
|
||||
if _icon != null: _icon.texture = texture; _icon.visible = texture != null
|
||||
@@ -38,8 +85,20 @@ func set_thumbnail(texture: Texture2D) -> void:
|
||||
func thumbnail_rect() -> TextureRect:
|
||||
return _icon
|
||||
|
||||
func set_selected(selected: bool) -> void:
|
||||
button_pressed = selected
|
||||
func set_selected(selected: bool, selected_surface: Color = Color("#12394A"), selected_border: Color = Color("#22C6FF")) -> void:
|
||||
toggle_mode = true
|
||||
set_pressed_no_signal(selected)
|
||||
if not selected:
|
||||
return
|
||||
var selected_style := StyleBoxFlat.new()
|
||||
selected_style.bg_color = selected_surface
|
||||
selected_style.border_color = selected_border
|
||||
selected_style.set_border_width_all(3)
|
||||
selected_style.set_corner_radius_all(8)
|
||||
add_theme_stylebox_override("normal", selected_style)
|
||||
add_theme_stylebox_override("pressed", selected_style)
|
||||
add_theme_stylebox_override("hover", selected_style)
|
||||
add_theme_stylebox_override("hover_pressed", selected_style)
|
||||
|
||||
func payload() -> Dictionary:
|
||||
return _payload.duplicate(true)
|
||||
|
||||
Reference in New Issue
Block a user