└── addons └── filesystem_drawer ├── default_shortcut.tres ├── plugin.cfg └── plugin.gd /addons/filesystem_drawer/default_shortcut.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Shortcut" load_steps=2 format=3 uid="uid://coupup08gdvj"] 2 | 3 | [sub_resource type="InputEventKey" id="InputEventKey_4g04k"] 4 | device = -1 5 | ctrl_pressed = true 6 | physical_keycode = 32 7 | unicode = 32 8 | 9 | [resource] 10 | events = [SubResource("InputEventKey_4g04k")] 11 | -------------------------------------------------------------------------------- /addons/filesystem_drawer/plugin.cfg: -------------------------------------------------------------------------------- 1 | [plugin] 2 | 3 | name="FileSystem Drawer" 4 | description="Converts the FileSystem dock to a FileSystem Drawer at the bottom of the editor." 5 | author="Jakob Bouchard" 6 | version="1.0.0" 7 | script="plugin.gd" 8 | -------------------------------------------------------------------------------- /addons/filesystem_drawer/plugin.gd: -------------------------------------------------------------------------------- 1 | @tool 2 | extends EditorPlugin 3 | ## Converts the FileSystem dock to a FileSystem Drawer at the bottom of the editor. 4 | 5 | const DRAWER_SETTING: StringName = "plugins/filesystem_drawer/drawer_enabled" 6 | const SHORTCUT_SETTING: StringName = "plugins/filesystem_drawer/shortcut" 7 | 8 | var _filesystem: FileSystemDock 9 | var _drawer: bool = true 10 | var _open: bool = false 11 | var _editor_settings: EditorSettings 12 | 13 | func _enter_tree() -> void: 14 | set_process(false) 15 | set_process_input(false) 16 | _filesystem = get_editor_interface().get_file_system_dock() 17 | # TODO: Get rid of this somehow? 18 | await get_tree().create_timer(0.1).timeout 19 | 20 | _editor_settings = get_editor_interface().get_editor_settings() 21 | _editor_settings.settings_changed.connect(_on_editor_settings_changed) 22 | _drawer = _get_or_set_drawer_setting() 23 | _get_or_set_shortcut() 24 | 25 | if _drawer: 26 | _move_filesystem_dock() 27 | set_process_input(true) 28 | 29 | 30 | func _input(event: InputEvent) -> void: 31 | if not _drawer: 32 | return 33 | 34 | var shortcut = _get_or_set_shortcut() 35 | if shortcut == null: 36 | return 37 | if not shortcut.matches_event(event) or not event.is_released() or event.is_echo(): 38 | return 39 | 40 | _open = not _open 41 | if _open: 42 | make_bottom_panel_item_visible(_filesystem) 43 | else: 44 | hide_bottom_panel() 45 | 46 | 47 | func _exit_tree() -> void: 48 | if _drawer: 49 | _drawer = false 50 | _move_filesystem_dock() 51 | 52 | 53 | func _get_or_set_drawer_setting() -> bool: 54 | if not _editor_settings.has_setting(DRAWER_SETTING): 55 | _editor_settings.set_setting(DRAWER_SETTING, true) 56 | _editor_settings.set_initial_value(DRAWER_SETTING, true, false) 57 | 58 | return _editor_settings.get_setting(DRAWER_SETTING) 59 | 60 | 61 | func _get_or_set_shortcut() -> Shortcut: 62 | if not _editor_settings.has_setting(SHORTCUT_SETTING): 63 | var default_shortcut := preload("./default_shortcut.tres") 64 | var path := default_shortcut.resource_path 65 | var property_info := { 66 | "name": SHORTCUT_SETTING, 67 | "type": TYPE_STRING, 68 | "hint": PROPERTY_HINT_FILE, 69 | "hint_string": "*.tres" 70 | } 71 | _editor_settings.set_setting(SHORTCUT_SETTING, path) 72 | _editor_settings.add_property_info(property_info) 73 | 74 | var shortcut_path: String = _editor_settings.get_setting(SHORTCUT_SETTING) 75 | if shortcut_path == "": 76 | return null 77 | 78 | return load(shortcut_path) 79 | 80 | 81 | func _move_filesystem_dock() -> void: 82 | if _drawer: 83 | remove_control_from_docks(_filesystem) 84 | add_control_to_bottom_panel(_filesystem, "FileSystem") 85 | 86 | # Setup padding 87 | var _padding: float = EditorInterface.get_editor_scale() * 75.0 88 | var size: Vector2 = _filesystem.get_parent().size 89 | _filesystem.get_child(3).get_child(0).size.y = size.y - _padding 90 | _filesystem.get_child(3).get_child(1).size.y = size.y - _padding 91 | else: 92 | remove_control_from_bottom_panel(_filesystem) 93 | add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BR, _filesystem) 94 | 95 | 96 | func _on_editor_settings_changed() -> void: 97 | if _get_or_set_drawer_setting() == _drawer: 98 | return 99 | 100 | _drawer = _get_or_set_drawer_setting() 101 | _move_filesystem_dock() 102 | --------------------------------------------------------------------------------