generated from mstar/godot-template
Code stuff
This commit is contained in:
parent
cf22890c16
commit
e58093b5a5
153 changed files with 11196 additions and 4 deletions
7
addons/Asset_Drawer/AssetDrawerShortcut.tres
Normal file
7
addons/Asset_Drawer/AssetDrawerShortcut.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="InputEventKey" format=3 uid="uid://bafyb8y38ahfh"]
|
||||
|
||||
[resource]
|
||||
device = -1
|
||||
ctrl_pressed = true
|
||||
keycode = 32
|
||||
unicode = 32
|
117
addons/Asset_Drawer/FileSystem.gd
Normal file
117
addons/Asset_Drawer/FileSystem.gd
Normal file
|
@ -0,0 +1,117 @@
|
|||
@tool
|
||||
extends EditorPlugin
|
||||
|
||||
## The root scene
|
||||
const ROOT: StringName = &"root"
|
||||
## Padding from the bottom when popped out
|
||||
const PADDING: int = 20
|
||||
## Padding from the bottom when not popped out
|
||||
const BOTTOM_PADDING: int = 60
|
||||
## Minimum height of the dock
|
||||
const MIN_HEIGHT: int = 50
|
||||
|
||||
## The file system
|
||||
var file_dock: FileSystemDock = null
|
||||
|
||||
var file_split_container: SplitContainer = null
|
||||
var file_tree: Tree = null
|
||||
var file_container: VBoxContainer = null
|
||||
var asset_drawer_shortcut: InputEventKey = InputEventKey.new()
|
||||
|
||||
## Toggle for when the file system is moved to bottom
|
||||
var files_bottom: bool = false
|
||||
var new_size: Vector2
|
||||
var initial_load: bool = false
|
||||
var showing: bool = false
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
# Add tool button to move shelf to editor bottom
|
||||
add_tool_menu_item("Files to Bottom", files_to_bottom)
|
||||
|
||||
init_file_dock()
|
||||
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
files_to_bottom()
|
||||
|
||||
# Prevent file tree from being shrunk on load
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
file_split_container.split_offset = 175
|
||||
|
||||
# Get shortcut
|
||||
asset_drawer_shortcut = preload("res://addons/Asset_Drawer/AssetDrawerShortcut.tres") as InputEventKey
|
||||
|
||||
func init_file_dock() -> void:
|
||||
# Get our file system
|
||||
file_dock = EditorInterface.get_file_system_dock()
|
||||
file_split_container = file_dock.get_child(3) as SplitContainer
|
||||
file_tree = file_split_container.get_child(0) as Tree
|
||||
file_container = file_split_container.get_child(1) as VBoxContainer
|
||||
|
||||
#region show hide filesystem
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not files_bottom:
|
||||
return
|
||||
|
||||
if asset_drawer_shortcut.is_match(event) and event.is_pressed() and not event.is_echo():
|
||||
if showing:
|
||||
hide_bottom_panel()
|
||||
else:
|
||||
make_bottom_panel_item_visible(file_dock)
|
||||
|
||||
showing = not showing
|
||||
#endregion
|
||||
|
||||
func _exit_tree() -> void:
|
||||
remove_tool_menu_item("Files to Bottom")
|
||||
files_to_bottom()
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var window := file_dock.get_window()
|
||||
new_size = window.size
|
||||
|
||||
# Keeps the file system from being unusable in size
|
||||
if window.name == ROOT and not files_bottom:
|
||||
file_tree.size.y = new_size.y - PADDING
|
||||
file_container.size.y = new_size.y - PADDING
|
||||
return
|
||||
|
||||
# Adjust the size of the file system based on how far up
|
||||
# the drawer has been pulled
|
||||
if window.name == ROOT and files_bottom:
|
||||
var dock_container := file_dock.get_parent() as Control
|
||||
new_size = dock_container.size
|
||||
var editorsettings := EditorInterface.get_editor_settings()
|
||||
var fontsize: int = editorsettings.get_setting("interface/editor/main_font_size")
|
||||
var editorscale := EditorInterface.get_editor_scale()
|
||||
|
||||
file_tree.size.y = new_size.y - (fontsize * 2) - (BOTTOM_PADDING * editorscale)
|
||||
file_container.size.y = new_size.y - (fontsize * 2) - (BOTTOM_PADDING * editorscale)
|
||||
return
|
||||
|
||||
# Keeps our systems sized when popped out
|
||||
if window.name != ROOT and not files_bottom:
|
||||
window.min_size.y = MIN_HEIGHT
|
||||
file_tree.size.y = new_size.y - PADDING
|
||||
file_container.size.y = new_size.y - PADDING
|
||||
|
||||
# Centers window on first pop
|
||||
if not initial_load:
|
||||
initial_load = true
|
||||
var screenSize: Vector2 = DisplayServer.screen_get_size()
|
||||
window.position = screenSize / 2
|
||||
|
||||
|
||||
# Moves the files between the bottom panel and the original dock
|
||||
func files_to_bottom() -> void:
|
||||
if files_bottom:
|
||||
remove_control_from_bottom_panel(file_dock)
|
||||
add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BR, file_dock)
|
||||
files_bottom = false
|
||||
return
|
||||
|
||||
init_file_dock()
|
||||
remove_control_from_docks(file_dock)
|
||||
add_control_to_bottom_panel(file_dock, "File System")
|
||||
files_bottom = true
|
21
addons/Asset_Drawer/LICENSE
Normal file
21
addons/Asset_Drawer/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Michael McGuire
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
7
addons/Asset_Drawer/plugin.cfg
Normal file
7
addons/Asset_Drawer/plugin.cfg
Normal file
|
@ -0,0 +1,7 @@
|
|||
[plugin]
|
||||
|
||||
name="Asset Drawer"
|
||||
description="Converts the File dock to an Asset Drawer at the bottom of the editor."
|
||||
author="GlitchedCode"
|
||||
version=""
|
||||
script="FileSystem.gd"
|
Loading…
Add table
Add a link
Reference in a new issue