Skip to content

Commit

Permalink
Fix bottom panel not appearing on click
Browse files Browse the repository at this point in the history
  • Loading branch information
TokisanGames committed Oct 9, 2024
1 parent 71d4553 commit b1c22f1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
10 changes: 5 additions & 5 deletions project/addons/terrain_3d/editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var godot_editor_window: Window # The Godot Editor window

func _init() -> void:
# Get the Godot Editor window. Structure is root:Window/EditorNode/Base Control
godot_editor_window = get_editor_interface().get_base_control().get_parent().get_parent()
godot_editor_window = EditorInterface.get_base_control().get_parent().get_parent()


func _enter_tree() -> void:
Expand All @@ -51,10 +51,10 @@ func _exit_tree() -> void:
scene_changed.disconnect(_on_scene_changed)


## EditorPlugin selection function chain isn't consistent. Here's the map of calls:
## EditorPlugin selection function call chain isn't consistent. Here's the map of calls:
## Assume we handle Terrain3D and NavigationRegion3D
# Click Terrain3D: _handles(Terrain3D), _make_visible(true), _edit(Terrain3D)
# Delect: _make_visible(false), _edit(null)
# Deselect: _make_visible(false), _edit(null)
# Click other node: _handles(OtherNode)
# Click NavRegion3D: _handles(NavReg3D), _make_visible(true), _edit(NavReg3D)
# Click NavRegion3D, Terrain3D: _handles(Terrain3D), _edit(Terrain3D)
Expand Down Expand Up @@ -282,7 +282,7 @@ func is_terrain_valid(p_terrain: Terrain3D = null) -> bool:


func is_selected() -> bool:
var selected: Array[Node] = get_editor_interface().get_selection().get_selected_nodes()
var selected: Array[Node] = EditorInterface.get_selection().get_selected_nodes()
for node in selected:
if ( is_instance_valid(_last_terrain) and node.get_instance_id() == _last_terrain.get_instance_id() ) or \
node is Terrain3D:
Expand All @@ -292,7 +292,7 @@ func is_selected() -> bool:

func select_terrain() -> void:
if is_instance_valid(_last_terrain) and is_terrain_valid(_last_terrain) and not is_selected():
var es: EditorSelection = get_editor_interface().get_selection()
var es: EditorSelection = EditorInterface.get_selection()
es.clear()
es.add_node(_last_terrain)

Expand Down
15 changes: 7 additions & 8 deletions project/addons/terrain_3d/src/asset_dock.gd
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func _ready() -> void:
# 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 plugin.get_editor_interface().get_edited_scene_root() != self:
if EditorInterface.get_edited_scene_root() != self:
pinned_btn.icon = get_theme_icon("Pin", "EditorIcons")
pinned_btn.text = ""
floating_btn.icon = get_theme_icon("MakeFloating", "EditorIcons")
Expand Down Expand Up @@ -195,8 +195,7 @@ func update_dock() -> void:
elif slot == POS_BOTTOM:
state = BOTTOM
plugin.add_control_to_bottom_panel(self, "Terrain3D")
if plugin.ui.visible:
plugin.make_bottom_panel_item_visible(self)
plugin.make_bottom_panel_item_visible(self)


func update_layout() -> void:
Expand Down Expand Up @@ -272,7 +271,7 @@ func _on_textures_pressed() -> void:
meshes_btn.button_pressed = false
texture_list.set_selected_id(texture_list.selected_id)
if plugin.is_terrain_valid():
plugin.get_editor_interface().edit_node(plugin.terrain)
EditorInterface.edit_node(plugin.terrain)
save_editor_settings()


Expand All @@ -285,7 +284,7 @@ func _on_meshes_pressed() -> void:
textures_btn.button_pressed = false
mesh_list.set_selected_id(mesh_list.selected_id)
if plugin.is_terrain_valid():
plugin.get_editor_interface().edit_node(plugin.terrain)
EditorInterface.edit_node(plugin.terrain)
update_thumbnails()
save_editor_settings()

Expand Down Expand Up @@ -374,7 +373,7 @@ func _on_window_input(event: InputEvent) -> void:
# Capture CTRL+S when doc focused to save scene
if event is InputEventKey and event.keycode == KEY_S and event.pressed and event.is_command_or_control_pressed():
save_editor_settings()
plugin.get_editor_interface().save_scene()
EditorInterface.save_scene()


func _on_godot_window_entered() -> void:
Expand Down Expand Up @@ -561,7 +560,7 @@ class ListContainer extends Container:

func _on_resource_inspected(p_resource: Resource) -> void:
await get_tree().create_timer(.01).timeout
plugin.get_editor_interface().edit_resource(p_resource)
EditorInterface.edit_resource(p_resource)


func _on_resource_changed(p_resource: Resource, p_id: int) -> void:
Expand Down Expand Up @@ -591,7 +590,7 @@ class ListContainer extends Container:

# If removing an entry, clear inspector
if not p_resource:
plugin.get_editor_interface().inspect_object(null)
EditorInterface.inspect_object(null)

# If null resource, remove last
if not p_resource:
Expand Down
10 changes: 5 additions & 5 deletions project/addons/terrain_3d/src/baker.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func bake_mesh_popup() -> void:
if plugin.terrain:
bake_method = _bake_mesh
bake_lod_dialog.description = BAKE_MESH_DESCRIPTION
plugin.get_editor_interface().popup_dialog_centered(bake_lod_dialog)
EditorInterface.popup_dialog_centered(bake_lod_dialog)


func _bake_mesh() -> void:
Expand Down Expand Up @@ -89,7 +89,7 @@ func bake_occluder_popup() -> void:
if plugin.terrain:
bake_method = _bake_occluder
bake_lod_dialog.description = BAKE_OCCLUDER_DESCRIPTION
plugin.get_editor_interface().popup_dialog_centered(bake_lod_dialog)
EditorInterface.popup_dialog_centered(bake_lod_dialog)


func _bake_occluder() -> void:
Expand Down Expand Up @@ -159,7 +159,7 @@ func find_nav_region_terrains(p_nav_region: NavigationRegion3D) -> Array[Terrain

func find_terrain_nav_regions(p_terrain: Terrain3D) -> Array[NavigationRegion3D]:
var result: Array[NavigationRegion3D] = []
var root: Node = plugin.get_editor_interface().get_edited_scene_root()
var root: Node = EditorInterface.get_edited_scene_root()
if not root:
return result
for nav_region in root.find_children("", "NavigationRegion3D", true, true):
Expand Down Expand Up @@ -338,7 +338,7 @@ func set_up_navigation_popup() -> void:
if plugin.terrain:
bake_method = _set_up_navigation
confirm_dialog.dialog_text = SET_UP_NAVIGATION_DESCRIPTION
plugin.get_editor_interface().popup_dialog_centered(confirm_dialog)
EditorInterface.popup_dialog_centered(confirm_dialog)


func _set_up_navigation() -> void:
Expand All @@ -363,7 +363,7 @@ func _set_up_navigation() -> void:
undo_redo.add_do_reference(nav_region)
undo_redo.commit_action()

plugin.get_editor_interface().inspect_object(nav_region)
EditorInterface.inspect_object(nav_region)
assert(plugin.nav_region == nav_region)

bake_nav_mesh()
Expand Down
16 changes: 8 additions & 8 deletions project/addons/terrain_3d/src/ui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ func _on_godot_focus_entered() -> void:


func set_visible(p_visible: bool, p_menu_only: bool = false) -> void:
if(plugin.editor):
if(p_visible):
await get_tree().create_timer(.01).timeout # Won't work, otherwise.
_on_tool_changed(last_tool, last_operation)
else:
plugin.editor.set_tool(Terrain3DEditor.TOOL_MAX)
plugin.editor.set_operation(Terrain3DEditor.OP_MAX)

terrain_menu.set_visible(p_visible)

if p_menu_only:
Expand All @@ -138,7 +130,15 @@ func set_visible(p_visible: bool, p_menu_only: bool = false) -> void:
tool_settings.set_visible(p_visible)
update_decal()

if(plugin.editor):
if(p_visible):
await get_tree().create_timer(.01).timeout # Won't work, otherwise.
_on_tool_changed(last_tool, last_operation)
else:
plugin.editor.set_tool(Terrain3DEditor.TOOL_MAX)
plugin.editor.set_operation(Terrain3DEditor.OP_MAX)


func set_menu_visibility(p_list: Control, p_visible: bool) -> void:
if p_list:
p_list.get_parent().get_parent().visible = p_visible
Expand Down

0 comments on commit b1c22f1

Please sign in to comment.