Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 34 additions & 28 deletions project/addons/terrain_3d/src/asset_dock.gd
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ var window: Window
var _godot_last_state: Window.Mode = Window.MODE_FULLSCREEN


func _notification(what: int) -> void:
if what == NOTIFICATION_ENTER_TREE:
await get_tree().process_frame
update_layout()


func initialize(p_plugin: EditorPlugin) -> void:
if p_plugin:
plugin = p_plugin
Expand Down Expand Up @@ -103,35 +109,30 @@ func initialize(p_plugin: EditorPlugin) -> void:
meshes_btn.add_theme_font_size_override("font_size", 16 * EditorInterface.get_editor_scale())
textures_btn.add_theme_font_size_override("font_size", 16 * EditorInterface.get_editor_scale())

_initialized = true
update_dock()
update_layout()


func _ready() -> void:
if not _initialized:
return

# Setup styles
set("theme_override_styles/panel", get_theme_stylebox("panel", "Panel"))
# Avoid saving icon resources in tscn when editing w/ a tool script
if EditorInterface.get_edited_scene_root() != self:
pinned_btn.icon = get_theme_icon("Pin", "EditorIcons")
pinned_btn.text = ""
search_button.icon = get_theme_icon("Search", "EditorIcons")

search_box.text_changed.connect(_on_search_text_changed)
search_button.pressed.connect(_on_search_button_pressed)

confirm_dialog = ConfirmationDialog.new()
add_child(confirm_dialog, true)
confirm_dialog.hide()
confirm_dialog.confirmed.connect(func(): _confirmed = true; \
emit_signal("confirmation_closed"); \
emit_signal("confirmation_confirmed") )
confirmation_closed.emit(); \
confirmation_confirmed.emit() )
confirm_dialog.canceled.connect(func(): _confirmed = false; \
emit_signal("confirmation_closed"); \
emit_signal("confirmation_canceled") )
confirmation_closed.emit(); \
confirmation_canceled.emit() )

# Setup styles
set("theme_override_styles/panel", get_theme_stylebox("panel", "Panel"))
# Avoid saving icon resources in tscn when editing w/ a tool script
if EditorInterface.get_edited_scene_root() != self:
pinned_btn.icon = get_theme_icon("Pin", "EditorIcons")
pinned_btn.text = ""
search_button.icon = get_theme_icon("Search", "EditorIcons")

_initialized = true
update_dock()
update_layout()


func _gui_input(p_event: InputEvent) -> void:
Expand Down Expand Up @@ -201,17 +202,21 @@ func update_dock() -> void:


func update_layout() -> void:
if plugin.debug > 1:
print("Terrain3DAssetDock: update_layout")
if not _initialized:
return
if plugin.debug > 1:
print("Terrain3DAssetDock: update_layout")


# Detect if we have a new window from Make floating, grab it so we can free it properly
if not window and get_parent() and get_parent().get_parent() is Window:
window = get_parent().get_parent()
make_dock_float()
if not window and get_parent() and get_parent().get_parent().get_parent() is Window:
window = get_parent().get_parent().get_parent()
return # Will call this function again upon display

elif window and get_parent() and not get_parent().get_parent().get_parent() is Window:
window = null
return # Will call this function again upon display


# Vertical layout: buttons on top
if size.x < 500 or ( not window and _dock_slot < EditorDock.DockSlot.DOCK_SLOT_BOTTOM ):
box.vertical = true
Expand All @@ -228,9 +233,10 @@ func update_layout() -> void:
search_box.reparent(buttons)
buttons.move_child(search_box, 0)
size_slider.reparent(buttons)
buttons.move_child(size_slider, 4)
buttons.move_child(size_slider, 3)
pinned_btn.reparent(box)

pinned_btn.visible = is_instance_valid(window)
save_editor_settings()


Expand Down