加两个插件

This commit is contained in:
yvmou_
2026-09-12 02:07:17 +08:00
parent 9bb2f9c87b
commit a02116a206
57 changed files with 5894 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025-present GDQuest
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.
@@ -0,0 +1,240 @@
@tool
extends Node
enum HttpRequestState {
IDLE,
FETCHING_RELEASE_INFO,
DOWNLOADING_BINARY,
}
const URL_GITHUB_API_LATEST_RELEASE = "https://api.github.com/repos/gdquest/GDScript-formatter/releases/latest"
signal installation_completed(binary_path: String)
signal installation_failed(error_message: String)
var http_request_state := HttpRequestState.IDLE
var http_request: HTTPRequest = HTTPRequest.new()
var formatter_cache_dir: String
func _init(cache_dir: String) -> void:
formatter_cache_dir = cache_dir
func _ready() -> void:
add_child(http_request)
http_request.request_completed.connect(_on_request_completed)
func install_or_update_formatter() -> void:
print("Starting GDScript formatter installation...")
http_request_state = HttpRequestState.FETCHING_RELEASE_INFO
http_request.request(URL_GITHUB_API_LATEST_RELEASE)
func _on_request_completed(
_http_result: int,
response_code: int,
_http_headers: PackedStringArray,
body: PackedByteArray,
) -> void:
if response_code != 200:
var error_message := "HTTP request failed. Response code: " + str(response_code)
push_error(error_message)
http_request_state = HttpRequestState.IDLE
installation_failed.emit(error_message)
return
match http_request_state:
HttpRequestState.FETCHING_RELEASE_INFO:
_process_response_latest_release(body)
HttpRequestState.DOWNLOADING_BINARY:
_process_response_download_file(body)
_:
var error_message := "Unexpected HTTP request state: " + str(http_request_state)
push_error(error_message)
http_request_state = HttpRequestState.IDLE
installation_failed.emit(error_message)
func _process_response_latest_release(body: PackedByteArray) -> void:
var json = JSON.parse_string(body.get_string_from_utf8())
if not json or not json.has("assets"):
var error_message := "Failed to parse release information from GitHub API"
push_error(error_message)
http_request_state = HttpRequestState.IDLE
installation_failed.emit(error_message)
return
print("GDScript Formatter release information loaded successfully")
var assets = json["assets"]
var tag = json["tag_name"]
var download_url := _find_matching_asset(assets, tag)
if download_url.is_empty():
var error_message := "No matching binary found for current platform"
push_error(error_message)
http_request_state = HttpRequestState.IDLE
installation_failed.emit(error_message)
return
print("Found compatible release, starting download...\n", "Download URL: ", download_url)
http_request_state = HttpRequestState.DOWNLOADING_BINARY
http_request.request(download_url)
func _process_response_download_file(body: PackedByteArray) -> void:
http_request_state = HttpRequestState.IDLE
print("Download completed successfully (", body.size(), " bytes)")
var asset_info := _get_platform_info()
if asset_info.is_empty():
var error_message := "Failed to determine platform information"
push_error(error_message)
installation_failed.emit(error_message)
return
print("Extracting and installing binary...")
var binary_path := _download_and_install_binary(body, asset_info)
if binary_path.is_empty():
var error_message := "Installation failed"
push_error(error_message)
installation_failed.emit(error_message)
return
print(
"\n".join(["GDScript formatter installed successfully!", "Binary location: " + binary_path]),
)
installation_completed.emit(binary_path)
func _get_platform_info() -> Dictionary:
var os_name := OS.get_name().to_lower()
var processor_name := OS.get_processor_name().to_lower()
var architecture := "x86_64"
if (
processor_name.contains("aarch64") or processor_name.contains("arm64")
or processor_name.contains("apple")
):
architecture = "aarch64"
elif processor_name.contains("x86_64") or processor_name.contains("amd64"):
architecture = "x86_64"
var binary_name := "gdscript-formatter"
if os_name.contains("windows"):
binary_name = "gdscript-formatter.exe"
var platform_info := { "architecture": architecture, "binary_name": binary_name }
if os_name.contains("windows"):
platform_info["os"] = "windows"
elif os_name.contains("linux"):
platform_info["os"] = "linux"
elif os_name.contains("macos") or os_name.contains("osx"):
platform_info["os"] = "macos"
return platform_info
func _find_matching_asset(assets: Array, tag: String) -> String:
var platform_info := _get_platform_info()
if platform_info.is_empty():
return ""
var expected_pattern := "gdscript-formatter-%s-%s-%s" % [
tag,
platform_info["os"],
platform_info["architecture"],
]
if platform_info["os"] == "windows":
expected_pattern += ".exe"
expected_pattern += ".zip"
for asset in assets:
var asset_name: String = asset["name"]
if asset_name == expected_pattern:
return asset["browser_download_url"]
return ""
func _download_and_install_binary(zip_data: PackedByteArray, platform_info: Dictionary) -> String:
var binary_name: String = platform_info["binary_name"]
# We get the contents of the zip file as a byte array. we need to write
# it to a file to be able to read it. We use a temporary file for that.
var temp_archive_path := formatter_cache_dir.path_join("temp_formatter_archive.zip")
print("Installing to cache directory: ", formatter_cache_dir)
# Create the gdquest cache directory if it doesn't exist
if not DirAccess.dir_exists_absolute(formatter_cache_dir):
var dir_result := DirAccess.make_dir_recursive_absolute(formatter_cache_dir)
if dir_result != OK:
push_error("Failed to create cache directory: ", formatter_cache_dir)
return ""
var temp_file := FileAccess.open(temp_archive_path, FileAccess.WRITE)
if not temp_file:
push_error("Failed to create temporary archive file")
return ""
temp_file.store_buffer(zip_data)
temp_file.close()
var zip_reader := ZIPReader.new()
var err := zip_reader.open(temp_archive_path)
if err != OK:
push_error("Failed to open ZIP archive from temporary file")
zip_reader.close()
DirAccess.remove_absolute(temp_archive_path)
return ""
var files := zip_reader.get_files()
var binary_data: PackedByteArray
var found_binary := false
var actual_binary_name := ""
for file_path in files:
if not file_path.ends_with("/"):
binary_data = zip_reader.read_file(file_path)
actual_binary_name = file_path.get_file()
found_binary = true
break
zip_reader.close()
DirAccess.remove_absolute(temp_archive_path)
if not found_binary:
push_error("No executable found in ZIP archive")
return ""
var binary_path := formatter_cache_dir.path_join(binary_name)
var file := FileAccess.open(binary_path, FileAccess.WRITE)
if not file:
push_error("Failed to create binary file at: ", binary_path)
return ""
file.store_buffer(binary_data)
file.close()
if not OS.get_name().to_lower().contains("windows"):
# This should be equivalent to setting the binary to permissions 755
const UNIX_EXECUTABLE_PERMISSIONS = (
FileAccess.UNIX_READ_OWNER | FileAccess.UNIX_WRITE_OWNER
| FileAccess.UNIX_EXECUTE_OWNER | FileAccess.UNIX_READ_GROUP
| FileAccess.UNIX_EXECUTE_GROUP | FileAccess.UNIX_READ_OTHER | FileAccess.UNIX_EXECUTE_OTHER
)
var permissions_error := FileAccess.set_unix_permissions(
binary_path,
UNIX_EXECUTABLE_PERMISSIONS,
)
if permissions_error != OK:
push_error("Failed to make formatter executable: ", binary_path)
DirAccess.remove_absolute(binary_path)
return ""
return binary_path
@@ -0,0 +1 @@
uid://ccblhowfwltqi
+166
View File
@@ -0,0 +1,166 @@
## This module handles adding a menu to the script editor with formatter commands.
## It safely locates the script editor's menu bar and adds our custom menu.
@tool
extends Node
signal menu_item_selected(command: String)
const MENU_TEXT = "Format"
const MENU_ITEMS = {
"format_script": "Format Current Script",
"lint_script": "Lint Current Script",
"reorder_code": "Reorder Code",
"install_update": "Install or Update Formatter",
"uninstall": "Uninstall Formatter",
"report_issue": "Report Issue",
"help": "Help",
}
var menu_button: MenuButton = null
var popup_menu: PopupMenu = null
func _ready() -> void:
# At the start we insert the menu in the script editor
var script_editor := EditorInterface.get_script_editor()
var last_menu_button := _find_last_menu_button(script_editor)
if not is_instance_valid(last_menu_button):
push_warning(
"GDScript Formatter: Could not find valid menu button in script editor. Menu will not be available. Use the command palette instead."
)
return
menu_button = MenuButton.new()
menu_button.text = MENU_TEXT
menu_button.switch_on_hover = true
menu_button.flat = false
menu_button.theme_type_variation = &"FlatMenuButton"
popup_menu = menu_button.get_popup()
_populate_menu()
popup_menu.id_pressed.connect(_on_menu_item_pressed)
last_menu_button.add_sibling(menu_button)
## Cleans up the menu from the script editor. Call this when disabling the
## plugin (in _exit_tree()).
func remove_formatter_menu() -> void:
if is_instance_valid(menu_button):
if is_instance_valid(popup_menu):
popup_menu.id_pressed.disconnect(_on_menu_item_pressed)
menu_button.queue_free()
menu_button = null
popup_menu = null
func update_menu(show_uninstall: bool) -> void:
if not is_instance_valid(popup_menu):
return
popup_menu.clear()
_populate_menu(show_uninstall)
## Searches for and returns the last menu node in the script editor top menu bar,
## or null if not found.
func _find_last_menu_button(script_editor: Control) -> MenuButton:
# The first child of the script editor should be a VBoxContainer (main container for the script editor main screen)
# Then the first child of that container should be an HBoxContainer (the menu bar)
# This is based on the current structure of Godot's script editor as of Godot 4.5
# Note: We add multiple checks in there with null returns mainly in case something changes in a future
if script_editor.get_child_count() == 0:
return null
var main_container := script_editor.get_child(0)
if not is_instance_valid(main_container) or not main_container is VBoxContainer:
return null
if main_container.get_child_count() == 0:
return null
var menu_bar := main_container.get_child(0)
if not is_instance_valid(menu_bar) or not menu_bar is HBoxContainer:
return null
# We reached the menu bar. So now we loop through all the children look for
# the last menu button, which would be the last menu in the menu list.
# Note: Here the goal is to insert the menu after the debug menu, but we
# don't check for the button text because "debug" would only work in English
# this should work in any language.
var last_menu_button: MenuButton = null
for child in menu_bar.get_children():
if child is MenuButton:
last_menu_button = child as MenuButton
return last_menu_button
func _populate_menu(show_uninstall: bool = true) -> void:
if not is_instance_valid(popup_menu):
return
var current_item_index := 0
popup_menu.add_item(MENU_ITEMS["format_script"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "format_script")
popup_menu.set_item_tooltip(
current_item_index,
"Run the GDScript Formatter over the current script",
)
current_item_index += 1
popup_menu.add_item(MENU_ITEMS["lint_script"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "lint_script")
popup_menu.set_item_tooltip(current_item_index, "Check the current script for linting issues")
current_item_index += 1
popup_menu.add_item(MENU_ITEMS["reorder_code"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "reorder_code")
popup_menu.set_item_tooltip(
current_item_index,
"Reorder the code elements in the current script according to the GDScript Style Guide",
)
popup_menu.add_separator()
# NOTE: When we add separators, it bumps the internal index of menu items.
# That's why we have to increase it even on separators. Otherwise the
# tooltip will lose sync.
current_item_index += 2
popup_menu.add_item(MENU_ITEMS["install_update"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "install_update")
popup_menu.set_item_tooltip(
current_item_index,
"Download the latest version of the GDScript Formatter",
)
if show_uninstall:
current_item_index += 1
popup_menu.add_item(MENU_ITEMS["uninstall"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "uninstall")
popup_menu.set_item_tooltip(
current_item_index,
"Remove the GDScript Formatter installed through this add-on from your computer",
)
popup_menu.add_separator()
# Bumped index by 1 extra step because of the previous separator.
current_item_index += 2
popup_menu.add_item(MENU_ITEMS["report_issue"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "report_issue")
popup_menu.set_item_tooltip(current_item_index, "Tell us about problems or bugs you found")
current_item_index += 1
popup_menu.add_item(MENU_ITEMS["help"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "help")
popup_menu.set_item_tooltip(current_item_index, "Learn how to use the GDScript Formatter")
func _on_menu_item_pressed(id: int) -> void:
if not is_instance_valid(popup_menu):
return
var command: String = popup_menu.get_item_metadata(id)
if not command.is_empty():
menu_item_selected.emit(command)
@@ -0,0 +1 @@
uid://bqwfn5bsuds1m
@@ -0,0 +1,7 @@
[plugin]
name="GDQuest GDScript Formatter"
description="A plugin to format GDScript code in the Godot editor using the GDScript Formatter from GDQuest."
author="GDQuest"
version="0.25.0"
script="plugin.gd"
File diff suppressed because it is too large Load Diff
@@ -0,0 +1 @@
uid://dqgr353xopp3y
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025-present GDQuest
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.
@@ -0,0 +1,6 @@
[configuration]
entry_symbol = "gdext_rust_init"
compatibility_minimum = 4.7
[libraries]
linux.debug.x86_64 = "res://addons/GDQuest_GDScript_formatter_standalone/bin/libgdscript_formatter_gdextension.so"
@@ -0,0 +1 @@
uid://dwlskvf853una
@@ -0,0 +1,145 @@
## This module handles adding a menu to the script editor with formatter commands.
## It safely locates the script editor's menu bar and adds our custom menu.
@tool
extends Node
signal menu_item_selected(command: String)
const MENU_TEXT = "Format"
const MENU_ITEMS = {
"format_script": "Format Current Script",
"lint_script": "Lint Current Script",
"reorder_code": "Reorder Code",
"update": "Update Formatter",
"report_issue": "Report Issue",
"help": "Help",
}
var menu_button: MenuButton = null
var popup_menu: PopupMenu = null
func _ready() -> void:
# At the start we insert the menu in the script editor
var script_editor := EditorInterface.get_script_editor()
var last_menu_button := _find_last_menu_button(script_editor)
if not is_instance_valid(last_menu_button):
push_warning("GDScript Formatter: Could not find valid menu button in script editor. Menu will not be available. Use the command palette instead.")
return
menu_button = MenuButton.new()
menu_button.text = MENU_TEXT
menu_button.switch_on_hover = true
menu_button.flat = false
menu_button.theme_type_variation = &"FlatMenuButton"
popup_menu = menu_button.get_popup()
_populate_menu()
popup_menu.id_pressed.connect(_on_menu_item_pressed)
last_menu_button.add_sibling(menu_button)
## Cleans up the menu from the script editor. Call this when disabling the
## plugin (in _exit_tree()).
func remove_formatter_menu() -> void:
if is_instance_valid(menu_button):
if is_instance_valid(popup_menu):
popup_menu.id_pressed.disconnect(_on_menu_item_pressed)
menu_button.queue_free()
menu_button = null
popup_menu = null
func update_menu() -> void:
if not is_instance_valid(popup_menu):
return
popup_menu.clear()
_populate_menu()
## Searches for and returns the last menu node in the script editor top menu bar,
## or null if not found.
func _find_last_menu_button(script_editor: Control) -> MenuButton:
# The first child of the script editor should be a VBoxContainer (main container for the script editor main screen)
# Then the first child of that container should be an HBoxContainer (the menu bar)
# This is based on the current structure of Godot's script editor as of Godot 4.5
# Note: We add multiple checks in there with null returns mainly in case something changes in a future
if script_editor.get_child_count() == 0:
return null
var main_container := script_editor.get_child(0)
if not is_instance_valid(main_container) or not main_container is VBoxContainer:
return null
if main_container.get_child_count() == 0:
return null
var menu_bar := main_container.get_child(0)
if not is_instance_valid(menu_bar) or not menu_bar is HBoxContainer:
return null
# We reached the menu bar. So now we loop through all the children look for
# the last menu button, which would be the last menu in the menu list.
# Note: Here the goal is to insert the menu after the debug menu, but we
# don't check for the button text because "debug" would only work in English
# this should work in any language.
var last_menu_button: MenuButton = null
for child in menu_bar.get_children():
if child is MenuButton:
last_menu_button = child as MenuButton
return last_menu_button
func _populate_menu() -> void:
if not is_instance_valid(popup_menu):
return
var current_item_index := 0
popup_menu.add_item(MENU_ITEMS["format_script"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "format_script")
popup_menu.set_item_tooltip(current_item_index, "Run the GDScript Formatter over the current script")
current_item_index += 1
popup_menu.add_item(MENU_ITEMS["lint_script"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "lint_script")
popup_menu.set_item_tooltip(current_item_index, "Check the current script for linting issues")
current_item_index += 1
popup_menu.add_item(MENU_ITEMS["reorder_code"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "reorder_code")
popup_menu.set_item_tooltip(current_item_index, "Reorder the code elements in the current script according to the GDScript Style Guide")
popup_menu.add_separator()
# NOTE: When we add separators, it bumps the internal index of menu items.
# That's why we have to increase it even on separators. Otherwise the
# tooltip will lose sync.
current_item_index += 2
popup_menu.add_item(MENU_ITEMS["update"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "update")
popup_menu.set_item_tooltip(current_item_index, "Download the latest version of the GDScript Formatter")
popup_menu.add_separator()
# Bumped index by 1 extra step because of the previous separator.
current_item_index += 2
popup_menu.add_item(MENU_ITEMS["report_issue"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "report_issue")
popup_menu.set_item_tooltip(current_item_index, "Tell us about problems or bugs you found")
current_item_index += 1
popup_menu.add_item(MENU_ITEMS["help"], current_item_index)
popup_menu.set_item_metadata(current_item_index, "help")
popup_menu.set_item_tooltip(current_item_index, "Learn how to use the GDScript Formatter")
func _on_menu_item_pressed(id: int) -> void:
if not is_instance_valid(popup_menu):
return
var command: String = popup_menu.get_item_metadata(id)
if not command.is_empty():
menu_item_selected.emit(command)
@@ -0,0 +1 @@
uid://bqwpllr5ylrmb
@@ -0,0 +1,7 @@
[plugin]
name="GDQuest GDScript Formatter (Standalone)"
description="A plugin to format GDScript code in the Godot editor using the GDScript Formatter from GDQuest."
author="GDQuest"
version="0.22.2"
script="plugin.gd"
@@ -0,0 +1,641 @@
## This plug-in adds support for automatically formatting GDScript files on save
## and via a command in the Godot Editor, using the GDQuest GDScript Formatter.
##
## It also provides an option to install or update the formatter binary from the GitHub releases.
##
## See our website for more information on the formatter and how to use it:
## https://www.gdquest.com/library/gdscript_formatter/
@tool
extends EditorPlugin
const FormatterMenu = preload("menu.gd")
const EDITOR_SETTINGS_CATEGORY = "gdquest_gdscript_formatter/"
const SETTING_FORMAT_ON_SAVE = "format_on_save"
const SETTING_SHORTCUT = "shortcut"
const SETTING_USE_SPACES = "use_spaces"
const SETTING_INDENT_SIZE = "indent_size"
const SETTING_REORDER_CODE = "reorder_code"
const SETTING_SAFE_MODE = "safe_mode"
const SETTING_LINT_ON_SAVE = "lint_on_save"
const SETTING_LINT_LINE_LENGTH = "lint_line_length"
const SETTING_LINT_IGNORED_RULES = "lint_ignored_rules"
# Directories to ignore when Format on Save is enabled
const SETTING_IGNORED_DIRECTORIES = "format_on_save_ignored_directories"
const COMMAND_PALETTE_CATEGORY = "gdquest gdscript formatter/"
const COMMAND_PALETTE_FORMAT_SCRIPT = "Format GDScript"
const COMMAND_PALETTE_LINT_SCRIPT = "Lint GDScript"
const COMMAND_PALETTE_UPDATE = "Update Formatter"
const COMMAND_PALETTE_REPORT_ISSUE = "Report Issue"
var DEFAULT_SETTINGS = {
SETTING_FORMAT_ON_SAVE: false,
SETTING_USE_SPACES: false,
SETTING_INDENT_SIZE: 4,
SETTING_REORDER_CODE: false,
SETTING_SAFE_MODE: true,
SETTING_LINT_ON_SAVE: false,
SETTING_LINT_LINE_LENGTH: 100,
SETTING_LINT_IGNORED_RULES: "",
SETTING_IGNORED_DIRECTORIES: PackedStringArray(["addons/"]),
}
## Which gutter lint icons are shown in.
## By default, gutter 0 is for breakpoints and 1 is for things like overrides.
const GUTTER_LINT_ICON_INDEX = 2
const GUTTER_LINT_ICONS_NAME = "gdscript_formatter_lint_icons"
var connection_list: Array[Resource] = []
var menu: FormatterMenu = null
# Used to auto detect changes to the project's .editorconfig file.
var _editorconfig_last_modified_time := -1
# Editorconfig allows setting rules per path glob. We track globs for the format
# on save rule here so users can enable it selectively for specific folders.
var _editorconfig_format_on_save_rules: Array[Dictionary] = []
func _init() -> void:
for setting: String in DEFAULT_SETTINGS.keys():
if not has_editor_setting(setting):
set_editor_setting(setting, DEFAULT_SETTINGS[setting])
if not has_editor_setting(SETTING_SHORTCUT):
var default_shortcut := InputEventKey.new()
default_shortcut.echo = false
default_shortcut.pressed = true
default_shortcut.keycode = KEY_I
default_shortcut.ctrl_pressed = true
default_shortcut.shift_pressed = false
default_shortcut.alt_pressed = true
var shortcut := Shortcut.new()
shortcut.events.push_back(default_shortcut)
set_editor_setting(SETTING_SHORTCUT, shortcut)
func _enter_tree() -> void:
add_format_command()
add_lint_command()
add_update_command()
add_report_issue_command()
menu = FormatterMenu.new()
add_child(menu)
menu.menu_item_selected.connect(_on_menu_item_selected)
menu.update_menu()
update_shortcut()
resource_saved.connect(_on_resource_saved)
func _exit_tree() -> void:
resource_saved.disconnect(_on_resource_saved)
remove_format_command()
remove_lint_command()
remove_update_command()
remove_report_issue_command()
if is_instance_valid(menu):
menu.menu_item_selected.disconnect(_on_menu_item_selected)
menu.remove_formatter_menu()
menu.queue_free()
menu = null
func _shortcut_input(event: InputEvent) -> void:
var shortcut := get_editor_setting(SETTING_SHORTCUT) as Shortcut
if not is_instance_valid(shortcut):
return
if not shortcut.matches_event(event) or not event.is_pressed() or event.is_echo():
return
if format_current_script():
get_tree().root.set_input_as_handled()
func format_current_script() -> bool:
if not EditorInterface.get_script_editor().is_visible_in_tree():
return false
var current_script := EditorInterface.get_script_editor().get_current_script()
if not is_instance_valid(current_script) or not current_script is GDScript:
return false
var code_edit: CodeEdit = EditorInterface.get_script_editor().get_current_editor().get_base_editor()
var formatted_code := format_code(current_script, false, code_edit.text)
if formatted_code.is_empty():
return false
reload_code_edit(code_edit, formatted_code)
return true
func lint_current_script() -> bool:
if not EditorInterface.get_script_editor().is_visible_in_tree():
return false
var current_script := EditorInterface.get_script_editor().get_current_script()
if not is_instance_valid(current_script) or not current_script is GDScript:
return false
var code_edit: CodeEdit = EditorInterface.get_script_editor().get_current_editor().get_base_editor()
var lint_issues := lint_code(current_script)
if lint_issues.is_empty():
print("No linting issues found.")
clear_lint_highlights(code_edit)
return true
apply_lint_highlights(code_edit, lint_issues)
print_lint_summary(lint_issues, current_script.resource_path)
return true
func update_shortcut() -> void:
for obj: Resource in connection_list:
obj.changed.disconnect(update_shortcut)
connection_list.clear()
var shortcut := get_editor_setting(SETTING_SHORTCUT) as Shortcut
if is_instance_valid(shortcut):
for event: InputEvent in shortcut.events:
if is_instance_valid(event):
event.changed.connect(update_shortcut)
connection_list.push_back(event)
remove_format_command()
add_format_command()
func _on_resource_saved(saved_resource: Resource) -> void:
if saved_resource is not GDScript:
return
var script := saved_resource as GDScript
var do_format_on_save := get_editor_setting(SETTING_FORMAT_ON_SAVE) as bool
var editorconfig_format_on_save = get_editorconfig_format_on_save(script.resource_path)
if editorconfig_format_on_save != null:
do_format_on_save = editorconfig_format_on_save as bool
var lint_on_save := get_editor_setting(SETTING_LINT_ON_SAVE) as bool
if not do_format_on_save and not lint_on_save:
return
var ignored_directories = get_editor_setting(SETTING_IGNORED_DIRECTORIES)
var path = script.resource_path.trim_prefix("res://")
var script_path_parts := path.split("/")
for directory: String in ignored_directories:
var normalized_dir := directory.trim_prefix("res://")
var directory_parts := normalized_dir.split("/")
var matches := true
for i in range(directory_parts.size()):
if directory_parts[i] != script_path_parts[i]:
matches = false
break
if matches:
return
if not is_instance_valid(script):
return
if do_format_on_save:
var formatted_code := format_code(script, false)
if formatted_code.is_empty():
return
script.source_code = formatted_code
ResourceSaver.save(script)
# The argument (keep_state parameter) tells Godot to try to preserve the
# state of the script instance, like static variables. Without this,
# attempting to reload tool scripts will fail with an error because they
# are already instantiated in the editor and instantiated scripts are
# not allowed to force reload without unloading first.
script.reload(true)
var script_editor := EditorInterface.get_script_editor()
var open_script_editors := script_editor.get_open_script_editors()
var open_scripts := script_editor.get_open_scripts()
if not open_scripts.has(script):
return
if script_editor.get_current_script() == script:
reload_code_edit(script_editor.get_current_editor().get_base_editor(), formatted_code, true)
elif open_scripts.size() == open_script_editors.size():
for i: int in range(open_scripts.size()):
if open_scripts[i] == script:
reload_code_edit(open_script_editors[i].get_base_editor(), formatted_code, true)
return
else:
push_error("GDScript Formatter error: Unknown situation, can't reload code editor in Editor. Please report this issue.")
if lint_on_save:
var code_edit: CodeEdit = EditorInterface.get_script_editor().get_current_editor().get_base_editor()
var lint_issues := lint_code(script)
if lint_issues.is_empty():
clear_lint_highlights(code_edit)
else:
apply_lint_highlights(code_edit, lint_issues)
print_lint_summary(lint_issues, script.resource_path)
func add_format_command() -> void:
var shortcut := get_editor_setting(SETTING_SHORTCUT) as Shortcut
EditorInterface.get_command_palette().add_command(
COMMAND_PALETTE_FORMAT_SCRIPT,
COMMAND_PALETTE_CATEGORY + COMMAND_PALETTE_FORMAT_SCRIPT,
format_current_script,
shortcut.get_as_text() if is_instance_valid(shortcut) else "None",
)
func remove_format_command() -> void:
EditorInterface.get_command_palette().remove_command(COMMAND_PALETTE_CATEGORY + COMMAND_PALETTE_FORMAT_SCRIPT)
func add_lint_command() -> void:
EditorInterface.get_command_palette().add_command(
COMMAND_PALETTE_LINT_SCRIPT,
COMMAND_PALETTE_CATEGORY + COMMAND_PALETTE_LINT_SCRIPT,
lint_current_script,
)
func remove_lint_command() -> void:
EditorInterface.get_command_palette().remove_command(
COMMAND_PALETTE_CATEGORY + COMMAND_PALETTE_LINT_SCRIPT,
)
func add_update_command() -> void:
EditorInterface.get_command_palette().add_command(
COMMAND_PALETTE_UPDATE,
COMMAND_PALETTE_CATEGORY + COMMAND_PALETTE_UPDATE,
# TODO: Implement me
func() -> void: push_error("Update command not implemented!"),
)
func remove_update_command() -> void:
EditorInterface.get_command_palette().remove_command(COMMAND_PALETTE_CATEGORY + COMMAND_PALETTE_UPDATE)
func add_report_issue_command() -> void:
EditorInterface.get_command_palette().add_command(
COMMAND_PALETTE_REPORT_ISSUE,
COMMAND_PALETTE_CATEGORY + COMMAND_PALETTE_REPORT_ISSUE,
report_issue,
)
func remove_report_issue_command() -> void:
EditorInterface.get_command_palette().remove_command(
COMMAND_PALETTE_CATEGORY + COMMAND_PALETTE_REPORT_ISSUE)
func reorder_code() -> bool:
if not EditorInterface.get_script_editor().is_visible_in_tree():
return false
var current_script := EditorInterface.get_script_editor().get_current_script()
if not is_instance_valid(current_script) or not current_script is GDScript:
return false
var code_edit: CodeEdit = EditorInterface.get_script_editor().get_current_editor().get_base_editor()
var formatted_code := format_code(current_script, true, code_edit.text)
if formatted_code.is_empty():
return false
reload_code_edit(code_edit, formatted_code)
return true
func report_issue() -> void:
OS.shell_open("https://github.com/GDQuest/GDScript-formatter/issues")
func show_help() -> void:
OS.shell_open("https://www.gdquest.com/library/gdscript_formatter/")
func _on_menu_item_selected(command: String) -> void:
match command:
"format_script":
format_current_script()
"lint_script":
lint_current_script()
"reorder_code":
reorder_code()
"update":
# TODO: Implement me
push_error("update not implemented!")
"report_issue":
report_issue()
"help":
show_help()
_:
push_warning("Unsupported command sent from the menu: " + command)
## Reloads the code editor with new text while preserving editor state.
## This includes cursor position, scroll position, breakpoints, bookmarks, and folds.
func reload_code_edit(
code_edit: CodeEdit,
new_text: String,
tag_saved := false,
) -> void:
var editor_state := CodeEditState.new(code_edit)
code_edit.text = new_text
if tag_saved:
code_edit.tag_saved_version()
editor_state.restore_to_editor(code_edit)
code_edit.update_minimum_size()
code_edit.text_changed.emit()
func get_editor_setting(setting_name: String) -> Variant:
var editor_settings := EditorInterface.get_editor_settings()
var full_setting_key := EDITOR_SETTINGS_CATEGORY + setting_name
if editor_settings.has_setting(full_setting_key):
return editor_settings.get_setting(full_setting_key)
return DEFAULT_SETTINGS[setting_name]
func set_editor_setting(setting_name: String, value: Variant) -> void:
var editor_settings := EditorInterface.get_editor_settings()
var full_setting_key := EDITOR_SETTINGS_CATEGORY + setting_name
editor_settings.set_setting(full_setting_key, value)
func has_editor_setting(setting_name: String) -> bool:
var editor_settings := EditorInterface.get_editor_settings()
var full_setting_key := EDITOR_SETTINGS_CATEGORY + setting_name
return editor_settings.has_setting(full_setting_key)
## Returns true if this script should be formatted automatically on save, based
## on the project's .editorconfig file. Returns false if the config says not to
## format on save. Returns null if no rule matches (then it's the user editor
## settings that take over).
func get_editorconfig_format_on_save(script_path: String) -> Variant:
var editorconfig_path := ProjectSettings.globalize_path("res://.editorconfig")
var modified_time := FileAccess.get_modified_time(editorconfig_path)
if modified_time != _editorconfig_last_modified_time:
_editorconfig_last_modified_time = modified_time
_editorconfig_format_on_save_rules.clear()
load_editorconfig_format_on_save_rules(editorconfig_path)
var relative_script_path := script_path.trim_prefix("res://")
var format_on_save = null
for rule: Dictionary in _editorconfig_format_on_save_rules:
var pattern := rule["pattern"] as String
if pattern.is_empty() or editorconfig_section_matches(pattern, relative_script_path):
format_on_save = rule["format_on_save"]
return format_on_save
## Loads the project editorconfig file and parses format on save rules.
func load_editorconfig_format_on_save_rules(editorconfig_path: String) -> void:
var editorconfig_file := FileAccess.open(editorconfig_path, FileAccess.READ)
if editorconfig_file == null:
return
var pattern := ""
while not editorconfig_file.eof_reached():
var line := editorconfig_file.get_line().strip_edges()
if line.is_empty() or line.begins_with("#") or line.begins_with(";"):
continue
if line.begins_with("[") and line.ends_with("]"):
pattern = line.trim_prefix("[").trim_suffix("]")
continue
if not line.contains("="):
continue
var key_and_value := line.split("=", true, 1)
if key_and_value[0].strip_edges().to_lower() != "gdscript_formatter_format_on_save":
continue
match key_and_value[1].strip_edges().to_lower():
"true":
_editorconfig_format_on_save_rules.append({"pattern": pattern, "format_on_save": true})
"false":
_editorconfig_format_on_save_rules.append({"pattern": pattern, "format_on_save": false})
editorconfig_file.close()
## Returns true if an EditorConfig section applies to a saved script.
## pattern: The EditorConfig pattern to match against.
## relative_script_path: The path of the script relative to the project root.
func editorconfig_section_matches(pattern: String, relative_script_path: String) -> bool:
if pattern.is_empty():
return false
var normalized_pattern := pattern.trim_prefix("/")
var matching_path := relative_script_path
# If there's no / in the pattern it means this pattern targets a filename.
# It's not a folder/path glob pattern.
if not normalized_pattern.contains("/"):
matching_path = relative_script_path.get_file()
return matching_path.match(normalized_pattern)
## Formats GDScript code using the GDScript Formatter and returns it as a string.
## When source_content is null, reads the code from the GDScript resource directly.
## Otherwise, formats source_content without reading from the file.
##
## Pass a string through source_content when the user is editing the script in
## the editor and requests formatting without having saved their changes (in
## that case, the code they're editing only exists in the script editor's open
## tab).
func format_code(script: GDScript, force_reorder := false, source_content: Variant = null) -> String:
var script_path := script.resource_path
if source_content == null and script_path.is_empty():
push_error("GDScript Formatter Error: Can't format an unsaved script.")
return ""
if source_content == null:
source_content = script.source_code
var printer_config := {}
var formatter_config := { printer = printer_config }
if get_editor_setting(SETTING_USE_SPACES):
printer_config[SETTING_USE_SPACES] = true
printer_config[SETTING_INDENT_SIZE] = get_editor_setting(SETTING_INDENT_SIZE)
if force_reorder or get_editor_setting(SETTING_REORDER_CODE):
formatter_config[SETTING_REORDER_CODE] = true
if get_editor_setting(SETTING_SAFE_MODE):
formatter_config[SETTING_SAFE_MODE] = true
return GDScriptFormatter.format_gdscript(source_content, formatter_config)
## Lints a GDScript file using the GDScript Formatter's linter,
## and returns an array of lint issues.
func lint_code(script: GDScript) -> Array:
if script.resource_path.is_empty():
push_error("GDScript Formatter Error: Can't format an unsaved script.")
return []
var linter_config := {
max_line_length = get_editor_setting(SETTING_LINT_LINE_LENGTH) as int,
disabled_rules = ",".split(
get_editor_setting(SETTING_LINT_IGNORED_RULES) as String),
}
return GDScriptFormatter.lint_gdscript(script.source_code, linter_config)
## Applies lint highlighting to the code editor
func apply_lint_highlights(code_edit: CodeEdit, issues: Array) -> void:
clear_lint_highlights(code_edit)
# Add and set up gutter for lint icons if not already present.
# We check by name to avoid conflicts with gutters added by other addons.
# Once added, the gutter is never removed so the layout doesn't shift on clear.
var has_lint_gutter := false
for i: int in code_edit.get_gutter_count():
if code_edit.get_gutter_name(i) == GUTTER_LINT_ICONS_NAME:
has_lint_gutter = true
break
if not has_lint_gutter:
code_edit.add_gutter(GUTTER_LINT_ICON_INDEX)
code_edit.set_gutter_name(GUTTER_LINT_ICON_INDEX, GUTTER_LINT_ICONS_NAME)
code_edit.set_gutter_type(GUTTER_LINT_ICON_INDEX, CodeEdit.GutterType.GUTTER_TYPE_ICON)
const EDITOR_ICON_DEFAULT_WIDTH = 16.0
code_edit.set_gutter_width(GUTTER_LINT_ICON_INDEX, EDITOR_ICON_DEFAULT_WIDTH * EditorInterface.get_editor_scale())
for issue in issues:
var line_number: int = issue.line - 1 # Convert to zero-indexed
var severity: String = issue.severity
var color := Color(1, 0, 0, 0.1) if severity == "error" else Color(1, 1, 0, 0.1)
code_edit.set_line_background_color(line_number, color)
var icon_name := "StatusError" if severity == "error" else "StatusWarning"
var icon := EditorInterface.get_editor_theme().get_icon(icon_name, "EditorIcons")
code_edit.set_line_gutter_icon(line_number, GUTTER_LINT_ICON_INDEX, icon)
## Prints a detailed summary of lint issues to the output
func print_lint_summary(issues: Array, script_path: String) -> void:
print_rich("\n[b]=== Linting Results for %s ===[/b]\n" % script_path)
print_rich("[b]Found [i]%s[/i] issue(s)\n[/b]" % issues.size())
for issue in issues:
var line_display = str(issue.line)
var severity_label = issue.severity.to_upper()
print_rich(
"[color=%s]%s[/color] on line [color=cyan]%s[/color] ([i]%s[/i])" % [
"red" if severity_label == "ERROR" else "yellow",
severity_label,
line_display,
issue.rule,
],
)
print_rich("[i]%s[/i]\n" % [issue.message])
print_rich("[b]=== End Linting Results ===[/b]\n")
## Clears all lint highlighting from the code editor.
## The lint gutter is intentionally kept so the layout does not shift.
func clear_lint_highlights(code_edit: CodeEdit) -> void:
var lint_gutter_index := -1
for i: int in code_edit.get_gutter_count():
if code_edit.get_gutter_name(i) == GUTTER_LINT_ICONS_NAME:
lint_gutter_index = i
break
for line in range(code_edit.get_line_count()):
code_edit.set_line_background_color(line, Color(0, 0, 0, 0))
if lint_gutter_index != -1:
code_edit.set_line_gutter_icon(line, lint_gutter_index, null)
## Data structure to hold code editor state information
class CodeEditState:
var caret_line: int
var caret_column: int
var horizontal_scroll: int
var vertical_scroll: int
var breakpoints: Dictionary[int, String] = { }
var bookmarks: Dictionary[int, String] = { }
var folds: Dictionary[int, String] = { }
var code_edit: CodeEdit
func _init(code_edit: CodeEdit) -> void:
self.code_edit = code_edit
caret_line = code_edit.get_caret_line()
caret_column = code_edit.get_caret_column()
horizontal_scroll = code_edit.scroll_horizontal
vertical_scroll = code_edit.scroll_vertical
for line in code_edit.get_breakpointed_lines():
breakpoints[line] = code_edit.get_line(line)
for line in code_edit.get_bookmarked_lines():
bookmarks[line] = code_edit.get_line(line)
for line in code_edit.get_folded_lines():
folds[line] = code_edit.get_line(line)
func restore_to_editor(code_edit: CodeEdit) -> void:
var new_line_count := code_edit.get_line_count()
_restore_line_features(breakpoints, code_edit.set_line_as_breakpoint, new_line_count)
_restore_line_features(bookmarks, code_edit.set_line_as_bookmarked, new_line_count)
_restore_line_features(folds, func(line: int, _is_folded: bool) -> void: code_edit.fold_line(line), new_line_count)
code_edit.set_caret_line(caret_line)
code_edit.set_caret_column(caret_column)
code_edit.scroll_horizontal = horizontal_scroll
code_edit.scroll_vertical = vertical_scroll
## Restores line-based features (breakpoints, bookmarks, folds) by finding the best matching lines
## in the new text based on similarity to the original line text.
##
## Big thanks to https://github.com/Daylily-Zeleen/GDScript-Formatter for this approach.
func _restore_line_features(
stored_features: Dictionary,
set_line_func: Callable,
new_line_count: int,
) -> void:
var stored_lines := PackedInt64Array(stored_features.keys())
for line_index in range(stored_lines.size()):
var original_line := stored_lines[line_index] as int
var original_text := stored_features[original_line] as String
# After formatting lines can move, so we need to find the best match for the original line
# to restore the breakpoints, bookmarks, and folds.
# We first check the same line, then we expand our search outwards until we find a match.
# We use a similarity threshold of 0.9 to account for minor changes in the line text.
# This should be sufficient for most cases, but might need adjustment for edge cases.
# If no match is found, we skip restoring this feature
if original_line < new_line_count and code_edit.get_line(original_line).similarity(original_text) > 0.9:
set_line_func.call(original_line, true)
continue
var line_above := original_line - 1
var line_below := original_line + 1
while line_above >= 0 or line_below < new_line_count:
if line_below < new_line_count and code_edit.get_line(line_below).similarity(original_text) > 0.9:
set_line_func.call(line_below, true)
break
if line_above >= 0 and code_edit.get_line(line_above).similarity(original_text) > 0.9:
set_line_func.call(line_above, true)
break
line_above -= 1
line_below += 1
@@ -0,0 +1 @@
uid://ikxq6eiwl3ey
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Marius Hanl
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.
+142
View File
@@ -0,0 +1,142 @@
# Script IDE
Transforms the Script UI into an IDE like UI.
Multiline Tabs, Splitting, Outline with unique icons that shows all members of the script.
Quick search and function override functionality.
## Features
### Scripts as Tabs
- Scripts are now shown as Multiline Tab
- Script Tab can be split showing the current Script as readonly CodeEdit next to the main one.
The original script can be reopened by right-clicking it
- Scripts can be opened in a Popup with a shortcut or when clicking the three dots on the top right of the Tabs for quick navigation between scripts
- The currently edited script is automatically selected in the Filesystem Dock
### Outline with all members
- The Outline got an overhaul and showed more than just the methods of the script.
It includes the following members (types) with a unique icon:
- Classes (Red Square)
- Constants (Red Circle)
- Signals (Yellow)
- Export variables (Orange)
- (Static) Variables (Red)
- Engine callback functions (Blue)
- (Static) Functions (Green)
- Setter functions (Green circle, with an arrow inside it pointing to the right)
- Getter functions (Green circle, with an arrow inside it pointing to the left)
- All different member types of the script can be hidden or made visible again by the outline filter.
This allows fine control of what should be visible (e.g., only signals, (Godot) functions, ...)
- A `Right Click` enables only the clicked filter, another `Right Click` will enable all filters again
- The Outline can be opened in a Popup with a shortcut for quick navigation without the mouse
- You can navigate through the Outline with the `Arrow` keys (or `Page up/Page down`) and scroll to the selected item by pressing `ENTER`
### Quick search / override
- Files can be quickly searched by the Quick Search Popup with `Shift`+`Shift`
- You can find and quickly override any method from your super classes with `Alt`+`Ins`
## Customization
- The Outline is on the right side (can be changed to be on the left side again)
- The Outline can be toggled via `File -> Toggle Scripts Panel`. This will hide or show it
- The order in the Outline can be changed
- There is also the possibility to hide private members, this is all members starting with a `_`
- The Script ItemList is not visible by default but can be made visible again
### Settings
All settings can be changed in the `Editor Settings` under `Plugin` -> `Script Ide`.
- `Open Outline Popup` = Shortcut to control how the Outline Popup should be triggered
(default=CTRL+O or META+O)
- `Outline Position Right` = Flag to control whether the outline should be on the right or on the left side of the script editor
(default=true)
- `Outline Order` = List which specifies the order of all different types in the Outline
- `Hide Private Members` = Flag to control whether private members (methods/variables/constants starting with '_') should be hidden in the Outline or not
(default=false)
- `Open Script Popup` = Shortcut to control how the Script Popup should be triggered
(default=CTRL+U or META+U)
- `Script List Visible` = Flag to control whether the script list should still be visible or not (above the outline)
(default=false)
- `Script Tabs Singleline` = Flag to control whether the script tabs should be in a single line (instead of multiline)
(default=false)
- `Script Tabs Visible` = Flag to control whether the script tabs should be visible or not
(default=true)
- `Script Tabs Position Top` = Flag to control whether the script tabs should be on the top or on the bottom
(default=true)
- `Script Tabs Close Button Always` = Flag to control whether the script tabs should always have the close button or only the select tab
(default=false)
- `Auto Navigate in FileSystem Dock` = Flag to control whether the script that is currently edited should be automatically selected in the Filesystem Dock
(default=true)
- `Open Quick Search Popup` = Shortcut to control how the Quick Search Popup should be triggered
(default=Shift+Shift, double press behavior is hardcoded for now)
- `Open Quick Search Popup Scenes` = Shortcut to open the Quick Search Popup with the Scene Tab activated
(default=CTRL+N or META+N)
- `Open Quick Search Popup Scripts` = Shortcut to open the Quick Search Popup with the Script Tab activated
(default=CTRL+SHIFT+N or META+SHIFT+N)
- `Open Quick Search Popup Resources` = Shortcut to open the Quick Search Popup with the Resource Tab activated
(default=CTRL+SHIFT+ALT+N or META+SHIFT+ALT+N)
- `Open Override Popup` = Shortcut to control how the Override Popup should be triggered
(default=Alt+Ins)
- `Cycle Tab forward` = Shortcut to cycle the script tabs in the forward direction (only works in the 'Script' Editor Tab)
(default=CTRL+TAB)
- `Cycle Tab backward` = Shortcut to cycle the script tabs in the backward direction (only works in the 'Script' Editor Tab)
(default=CTRL+SHIFT+TAB)
- All outline visibility settings
## Screenshots
![Example of Script-IDE](https://github.com/Maran23/script-ide/blob/demo/demo/editor.webp?raw=true)
![Example of the Outline Popup](https://github.com/Maran23/script-ide/blob/demo/demo/outline.webp?raw=true)
![Example of the Script Tabs Popup](https://github.com/Maran23/script-ide/blob/demo/demo/tab_scripts.webp?raw=true)
![Example of the Quick Search Popup](https://github.com/Maran23/script-ide/blob/demo/demo/quick_search.webp?raw=true)
![Example of the Override Popup](https://github.com/Maran23/script-ide/blob/demo/demo/override.webp?raw=true)
![Example of Script Splitting](https://github.com/Maran23/script-ide/blob/demo/demo/script_split.webp?raw=true)
![Example of the Settings](https://github.com/Maran23/script-ide/blob/demo/demo/settings.webp?raw=true)
## Videos
- [Gamefromscratch](https://www.youtube.com/watch?v=ALshYw7K7Bs)
## Links
- [Asset Store](https://store.godotengine.org/asset/maran23/script-ide/)
- [Asset Library](https://godotengine.org/asset-library/asset/2206)
## Further notes
- This plugin tries to modify as little as possible in the Engine.
Since each version can introduce changes in the layout, every change can risk stability.
- The plugin initialization will fail fast if something is unexpected. A log message is printed and nothing else will be changed.
- The plugin code is aware of the structure in 'script_editor_plugin.cpp', which is the native part of the script tree structure that this plugin modifies
- This plugin is written with performance in mind:
- Everything that you might not use will also not consume any resources.
- Example: The quick open menu will only rebuild (lazily) when you open it
- There are no unneeded features.
- Example: If the functionality is most likely not relevant for many users, it probably should be its own plugin
### Contributing
In order to open this project in the Engine, you need to create (or copy) a `project.godot` into it.
Example file:
```properties
config_version=5
[application]
config/name="Script-IDE"
config/features=PackedStringArray("4.7")
config/icon="uid://eln8vh0yruef"
[editor_plugins]
enabled=PackedStringArray("res://addons/script-ide/plugin.cfg")
```
+1
View File
@@ -0,0 +1 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><rect x="1" y="1" width="14" height="14" fill="#ff7085"/></svg>

After

Width:  |  Height:  |  Size: 127 B

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://csik7oxvt7tq3"
path="res://.godot/imported/class.svg-9e3f3363c9474e8c1dcf8ba4e40e95bf.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/script-ide/outline/icon/class.svg"
dest_files=["res://.godot/imported/class.svg-9e3f3363c9474e8c1dcf8ba4e40e95bf.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
@@ -0,0 +1 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.866 0-7 3.134-7 7 0 3.866 3.134 7 7 7s7-3.134 7-7c0-3.866-3.134-7-7-7zm0 2c2.7614 0 5 2.2386 5 5 0 2.7614-2.2386 5-5 5-2.7614 0-5-2.2386-5-5 0-2.7614 2.2386-5 5-5z" fill="#ff7085"/></svg>

After

Width:  |  Height:  |  Size: 268 B

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cawc456ja8vf5"
path="res://.godot/imported/constant.svg-b36d0d3f8bf0f157e4f3b418b692e11b.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/script-ide/outline/icon/constant.svg"
dest_files=["res://.godot/imported/constant.svg-b36d0d3f8bf0f157e4f3b418b692e11b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
@@ -0,0 +1 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.866 0-7 3.134-7 7 0 3.866 3.134 7 7 7 3.866 0 7-3.134 7-7 0-3.866-3.134-7-7-7z" fill="#57b3ff"/></svg>

After

Width:  |  Height:  |  Size: 183 B

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cupb0polhqrwj"
path="res://.godot/imported/engine_func.svg-eb6c615eeef058e7cc5ec3b5a17fc008.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/script-ide/outline/icon/engine_func.svg"
dest_files=["res://.godot/imported/engine_func.svg-eb6c615eeef058e7cc5ec3b5a17fc008.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
@@ -0,0 +1 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.866 0-7 3.134-7 7 0 3.866 3.134 7 7 7 3.866 0 7-3.134 7-7 0-3.866-3.134-7-7-7z" fill="#ffb273"/></svg>

After

Width:  |  Height:  |  Size: 183 B

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bvu2gnj8fv2kw"
path="res://.godot/imported/export.svg-b7770a5f2f99766591abd69aca087dfc.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/script-ide/outline/icon/export.svg"
dest_files=["res://.godot/imported/export.svg-b7770a5f2f99766591abd69aca087dfc.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
+1
View File
@@ -0,0 +1 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.866 0-7 3.134-7 7 0 3.866 3.134 7 7 7 3.866 0 7-3.134 7-7 0-3.866-3.134-7-7-7z" fill="#8eef97"/></svg>

After

Width:  |  Height:  |  Size: 183 B

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://rni04cl446ov"
path="res://.godot/imported/func.svg-d034576bf2eed84b270a8dc1d6d64df6.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/script-ide/outline/icon/func.svg"
dest_files=["res://.godot/imported/func.svg-d034576bf2eed84b270a8dc1d6d64df6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
@@ -0,0 +1 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 15c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm0.5-2a1 1 0 0 1-0.70703-0.29297l-4-4a1 1 0 0 1-0.25977-0.62695 1.0001 1.0001 0 0 1 0-0.16016 1 1 0 0 1 0.25977-0.62695l4-4a1 1 0 0 1 1.4141 0 1 1 0 0 1 0 1.4141l-2.293 2.293h4.5859a1 1 0 0 1 1 1 1 1 0 0 1-1 1h-4.5859l2.293 2.293a1 1 0 0 1 0 1.4141 1 1 0 0 1-0.70703 0.29297z" fill="#8eef97"/></svg>

After

Width:  |  Height:  |  Size: 435 B

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c2a3aowyhxj5x"
path="res://.godot/imported/func_get.svg-033d200e05dd58beec3becc7967b8c7d.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/script-ide/outline/icon/func_get.svg"
dest_files=["res://.godot/imported/func_get.svg-033d200e05dd58beec3becc7967b8c7d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
@@ -0,0 +1 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.866 0-7 3.134-7 7 0 3.866 3.134 7 7 7s7-3.134 7-7c0-3.866-3.134-7-7-7zm-0.5 2a1 1 0 0 1 0.70703 0.29297l4 4a1 1 0 0 1 0.25977 0.62695 1.0001 1.0001 0 0 1 0 0.16016 1 1 0 0 1-0.25977 0.62695l-4 4a1 1 0 0 1-1.4141 0 1 1 0 0 1 0-1.4141l2.293-2.293h-4.5859a1 1 0 0 1-1-1 1 1 0 0 1 1-1h4.5859l-2.293-2.293a1 1 0 0 1 0-1.4141 1 1 0 0 1 0.70703-0.29297z" fill="#8eef97"/></svg>

After

Width:  |  Height:  |  Size: 451 B

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bvjkrti6kj6o2"
path="res://.godot/imported/func_set.svg-a9087ff3e7ab6aec141e34555a32a254.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/script-ide/outline/icon/func_set.svg"
dest_files=["res://.godot/imported/func_set.svg-a9087ff3e7ab6aec141e34555a32a254.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
@@ -0,0 +1 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.866 0-7 3.134-7 7 0 3.866 3.134 7 7 7 3.866 0 7-3.134 7-7 0-3.866-3.134-7-7-7z" fill="#ff7085"/></svg>

After

Width:  |  Height:  |  Size: 183 B

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dbwlgnwv5e8kl"
path="res://.godot/imported/property.svg-a9a1c76c01653424a37bad3c0caee2de.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/script-ide/outline/icon/property.svg"
dest_files=["res://.godot/imported/property.svg-a9a1c76c01653424a37bad3c0caee2de.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
@@ -0,0 +1 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.866 0-7 3.134-7 7 0 3.866 3.134 7 7 7 3.866 0 7-3.134 7-7 0-3.866-3.134-7-7-7z" fill="#ffdd65"/></svg>

After

Width:  |  Height:  |  Size: 183 B

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bnccvnaloqnte"
path="res://.godot/imported/signal.svg-65741ce388cd0a6b19f1b195a997cce3.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/script-ide/outline/icon/signal.svg"
dest_files=["res://.godot/imported/signal.svg-65741ce388cd0a6b19f1b195a997cce3.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
@@ -0,0 +1,25 @@
## Button that is used as in the outline for a concrete outline type.
@tool
extends Button
signal right_clicked
func _init() -> void:
toggle_mode = true
icon_alignment = HORIZONTAL_ALIGNMENT_CENTER
add_theme_stylebox_override(&"normal", StyleBoxEmpty.new())
add_theme_color_override(&"icon_pressed_color", Color.WHITE)
add_theme_color_override(&"icon_hover_color", Color.WHITE)
add_theme_color_override(&"icon_hover_pressed_color", Color.WHITE)
add_theme_color_override(&"icon_focus_color", Color.WHITE)
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton && event.pressed:
if (event.button_index == MOUSE_BUTTON_RIGHT):
button_pressed = true
on_right_click()
func on_right_click():
right_clicked.emit()
@@ -0,0 +1 @@
uid://c4fvj2xt46lgx
@@ -0,0 +1,544 @@
## The outline container shows a filter box and
## all script members with different color coding, depending of the type.
@tool
extends VBoxContainer
const GETTER: StringName = &"get"
const SETTER: StringName = &"set"
const UNDERSCORE: StringName = &"_"
const INLINE: StringName = &"@"
const BUILT_IN_SCRIPT: StringName = &"::GDScript"
#region Outline type name
const PROPERTY: StringName = &"property"
const TYPE: StringName = &"type"
const ENGINE_FUNCS: StringName = &"Engine Callbacks"
const FUNCS: StringName = &"Functions"
const SIGNALS: StringName = &"Signals"
const EXPORTED: StringName = &"Exported Properties"
const PROPERTIES: StringName = &"Properties"
const CLASSES: StringName = &"Classes"
const CONSTANTS: StringName = &"Constants"
const DEFAULT_ORDER: PackedStringArray = [ENGINE_FUNCS, FUNCS, SIGNALS, EXPORTED, PROPERTIES, CONSTANTS, CLASSES]
#endregion
const OutlineButton := preload("uid://c4fvj2xt46lgx")
const Plugin := preload("uid://bc0b5v66xdidn")
@onready var filter_box: HBoxContainer = %FilterBox
@onready var outline: ItemList = %Outline
var plugin: Plugin
#region Existing Engine controls we modify
var outline_filter_txt: LineEdit
#endregion
#region Outline icons and buttons
var engine_func_icon: Texture2D
var func_icon: Texture2D
var func_get_icon: Texture2D
var func_set_icon: Texture2D
var property_icon: Texture2D
var export_icon: Texture2D
var signal_icon: Texture2D
var constant_icon: Texture2D
var class_icon: Texture2D
var class_btn: Button
var constant_btn: Button
var signal_btn: Button
var property_btn: Button
var export_btn: Button
var func_btn: Button
var engine_func_btn: Button
#endregion
var is_hide_private_members: bool = false : set = set_hide_private_members
var outline_order: PackedStringArray : set = set_outline_order
var outline_type_order: Array[OutlineType] = []
var outline_cache: OutlineCache
func _ready() -> void:
init_icons()
init_outline_order()
outline.item_selected.connect(find_in_outline_and_goto)
if (plugin == null):
return
engine_func_btn = create_filter_btn(engine_func_icon, ENGINE_FUNCS)
func_btn = create_filter_btn(func_icon, FUNCS)
signal_btn = create_filter_btn(signal_icon, SIGNALS)
export_btn = create_filter_btn(export_icon, EXPORTED)
property_btn = create_filter_btn(property_icon, PROPERTIES)
class_btn = create_filter_btn(class_icon, CLASSES)
constant_btn = create_filter_btn(constant_icon, CONSTANTS)
func update():
update_outline_cache()
update_outline()
func tab_changed():
var is_script: bool = get_current_script() != null
visible = is_script
update()
func find_in_outline_and_goto(selected_idx: int):
var script: Script = get_current_script()
if (!script):
return
var text: String = outline.get_item_text(selected_idx)
var metadata: Dictionary[StringName, StringName] = outline.get_item_metadata(selected_idx)
var modifier: StringName = metadata[&"modifier"]
var type: StringName = metadata[TYPE]
var type_with_text: String = type + " " + text
if (type == &"func"):
type_with_text = type_with_text.substr(0, type_with_text.find("("))
var source_code: String = script.get_source_code()
var lines: PackedStringArray = source_code.split("\n")
var index: int = 0
for line: String in lines:
# Easy case, like 'var abc'
if (line.begins_with(type_with_text)):
plugin.goto_line(index)
return
# We have an modifier, e.g. 'static'
if (modifier != &"" && line.begins_with(modifier)):
if (line.begins_with(modifier + " " + type_with_text)):
plugin.goto_line(index)
return
# Special case: An 'enum' is treated different.
elif (modifier == &"enum" && line.contains("enum " + text)):
plugin.goto_line(index)
return
# Hard case, probably something like '@onready var abc'
if (type == &"var" && line.contains(type_with_text)):
plugin.goto_line(index)
return
index += 1
push_error(type_with_text + " or " + modifier + " not found in source code")
## Initializes all plugin icons, while respecting the editor settings.
func init_icons():
engine_func_icon = create_editor_texture(load_rel("icon/engine_func.svg"))
func_icon = create_editor_texture(load_rel("icon/func.svg"))
func_get_icon = create_editor_texture(load_rel("icon/func_get.svg"))
func_set_icon = create_editor_texture(load_rel("icon/func_set.svg"))
property_icon = create_editor_texture(load_rel("icon/property.svg"))
export_icon = create_editor_texture(load_rel("icon/export.svg"))
signal_icon = create_editor_texture(load_rel("icon/signal.svg"))
constant_icon = create_editor_texture(load_rel("icon/constant.svg"))
class_icon = create_editor_texture(load_rel("icon/class.svg"))
func create_filter_btn(icon: Texture2D, type: StringName) -> Button:
var btn: OutlineButton = OutlineButton.new()
btn.icon = icon
btn.tooltip_text = type
var property: StringName = plugin.SCRIPT_IDE + type.to_lower().replace(" ", "_")
btn.set_meta(PROPERTY, property)
btn.set_meta(TYPE, type)
btn.button_pressed = plugin.get_setting(property, true)
btn.toggled.connect(on_filter_button_pressed.bind(btn))
btn.right_clicked.connect(on_right_click.bind(btn))
return btn
func on_right_click(btn: OutlineButton):
btn.button_pressed = true
var pressed_state: bool = false
for child: Node in filter_box.get_children():
var other_btn: Button = child
if (btn != other_btn):
pressed_state = pressed_state || other_btn.button_pressed
for child: Node in filter_box.get_children():
var other_btn: Button = child
if (btn != other_btn):
other_btn.button_pressed = !pressed_state
outline_filter_txt.grab_focus()
func on_filter_button_pressed(pressed: bool, btn: Button):
plugin.set_setting(btn.get_meta(PROPERTY), pressed)
update_outline()
## Initializes the outline type structure and sorts it based off the outline order.
func init_outline_order():
var outline_type: OutlineType = OutlineType.new()
outline_type.type_name = ENGINE_FUNCS
outline_type.add_to_outline = func(): add_to_outline_if_selected(engine_func_btn,
func(): add_to_outline(outline_cache.engine_funcs, engine_func_icon, &"func"))
outline_type_order.append(outline_type)
outline_type = OutlineType.new()
outline_type.type_name = FUNCS
outline_type.add_to_outline = func(): add_to_outline_if_selected(func_btn,
func(): add_to_outline_ext(outline_cache.funcs, get_func_icon, &"func", &"static"))
outline_type_order.append(outline_type)
outline_type = OutlineType.new()
outline_type.type_name = SIGNALS
outline_type.add_to_outline = func(): add_to_outline_if_selected(signal_btn,
func(): add_to_outline(outline_cache.signals, signal_icon, &"signal"))
outline_type_order.append(outline_type)
outline_type = OutlineType.new()
outline_type.type_name = EXPORTED
outline_type.add_to_outline = func(): add_to_outline_if_selected(export_btn,
func(): add_to_outline(outline_cache.exports, export_icon, &"var", &"@export"))
outline_type_order.append(outline_type)
outline_type = OutlineType.new()
outline_type.type_name = PROPERTIES
outline_type.add_to_outline = func(): add_to_outline_if_selected(property_btn,
func(): add_to_outline(outline_cache.properties, property_icon, &"var"))
outline_type_order.append(outline_type)
outline_type = OutlineType.new()
outline_type.type_name = CLASSES
outline_type.add_to_outline = func(): add_to_outline_if_selected(class_btn,
func(): add_to_outline(outline_cache.classes, class_icon, &"class"))
outline_type_order.append(outline_type)
outline_type = OutlineType.new()
outline_type.type_name = CONSTANTS
outline_type.add_to_outline = func(): add_to_outline_if_selected(constant_btn,
func(): add_to_outline(outline_cache.constants, constant_icon, &"const", &"enum"))
outline_type_order.append(outline_type)
func add_to_outline_if_selected(btn: Button, action: Callable):
if (btn.button_pressed):
action.call()
func update_outline_button_order():
var all_buttons: Array[Button] = [engine_func_btn, func_btn, signal_btn, export_btn, property_btn, class_btn, constant_btn]
all_buttons.sort_custom(sort_buttons_by_outline_order)
for btn: Button in all_buttons:
if (btn.get_parent() != null):
filter_box.remove_child(btn)
for btn: Button in all_buttons:
filter_box.add_child(btn)
func sort_buttons_by_outline_order(btn1: Button, btn2: Button) -> bool:
return sort_by_outline_order(btn1.get_meta(TYPE), btn2.get_meta(TYPE))
func sort_types_by_outline_order(type1: OutlineType, type2: OutlineType) -> bool:
return sort_by_outline_order(type1.type_name, type2.type_name)
func sort_by_outline_order(outline_type1: StringName, outline_type2: StringName) -> bool:
return outline_order.find(outline_type1) < outline_order.find(outline_type2)
func get_current_script() -> Script:
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
return script_editor.get_current_script()
func update_outline_cache():
outline_cache = null
var script: Script = get_current_script()
if (!script):
return
# Check if built-in script. In this case we need to duplicate it for whatever reason.
if (script.get_path().contains(BUILT_IN_SCRIPT)):
script = script.duplicate()
outline_cache = OutlineCache.new()
# Collect all script members.
for_each_script_member(script, func(array: Array[String], item: String): array.append(item))
# Remove script members that only exist in the base script (which includes the base of the base etc.).
# Note: The method that only collects script members without including the base script(s)
# is not exposed to GDScript.
var base_script: Script = script.get_base_script()
if (base_script != null):
for_each_script_member(base_script, func(array: Array[String], item: String): array.erase(item))
func for_each_script_member(script: Script, consumer: Callable):
# Functions / Methods
for dict: Dictionary in script.get_script_method_list():
var func_name: String = dict[&"name"]
if (plugin.keywords.has(func_name)):
func_name = create_function_signature(dict)
consumer.call(outline_cache.engine_funcs, func_name)
else:
if (is_hide_private_members && func_name.begins_with(UNDERSCORE)):
continue
# Inline getter/setter will normally be shown as '@...getter', '@...setter'.
# Since we already show the variable itself, we will skip those.
if (func_name.begins_with(INLINE)):
continue
func_name = create_function_signature(dict)
consumer.call(outline_cache.funcs, func_name)
# Properties / Exported variables
for dict: Dictionary in script.get_script_property_list():
var property: String = dict[&"name"]
if (is_hide_private_members && property.begins_with(UNDERSCORE)):
continue
var usage: int = dict[&"usage"]
if (usage & PROPERTY_USAGE_SCRIPT_VARIABLE):
if (usage & PROPERTY_USAGE_STORAGE && usage & PROPERTY_USAGE_EDITOR):
consumer.call(outline_cache.exports, property)
else:
consumer.call(outline_cache.properties, property)
# Static variables (are separated for whatever reason)
for dict: Dictionary in script.get_property_list():
var property: String = dict[&"name"]
if (is_hide_private_members && property.begins_with(UNDERSCORE)):
continue
var usage: int = dict[&"usage"]
if (usage & PROPERTY_USAGE_SCRIPT_VARIABLE):
consumer.call(outline_cache.properties, property)
# Signals
for dict: Dictionary in script.get_script_signal_list():
var signal_name: String = dict[&"name"]
consumer.call(outline_cache.signals, signal_name)
# Constants / Classes
for name_key: String in script.get_script_constant_map():
if (is_hide_private_members && name_key.begins_with(UNDERSCORE)):
continue
var object: Variant = script.get_script_constant_map().get(name_key)
# Inner classes have no source code, while a const of type GDScript has.
if (object is GDScript && !object.has_source_code()):
consumer.call(outline_cache.classes, name_key)
else:
consumer.call(outline_cache.constants, name_key)
func update_outline():
outline.clear()
if (outline_cache == null):
return
for outline_type: OutlineType in outline_type_order:
outline_type.add_to_outline.call()
func add_to_outline(items: Array[String], icon: Texture2D, type: StringName, modifier: StringName = &""):
add_to_outline_ext(items, func(str: String): return icon, type, modifier)
func add_to_outline_ext(items: Array[String], icon_callable: Callable, type: StringName, modifier: StringName = &""):
var text: String = outline_filter_txt.get_text()
if (is_sorted()):
items = items.duplicate()
items.sort_custom(func(str1: String, str2: String): return str1.naturalnocasecmp_to(str2) < 0)
for item: String in items:
if (text.is_empty() || text.is_subsequence_ofn(item)):
var icon: Texture2D = icon_callable.call(item)
outline.add_item(item, icon, true)
var dict: Dictionary[StringName, StringName] = {
TYPE: type,
&"modifier": modifier
}
outline.set_item_metadata(outline.item_count - 1, dict)
func get_func_icon(func_name: String) -> Texture2D:
var icon: Texture2D = func_icon
if (func_name.begins_with(GETTER)):
icon = func_get_icon
elif (func_name.begins_with(SETTER)):
icon = func_set_icon
return icon
func save_restore_filter() -> Array[bool]:
var button_flags: Array[bool] = []
for child: Node in filter_box.get_children():
var btn: Button = child
button_flags.append(btn.button_pressed)
btn.set_pressed_no_signal(true)
return button_flags
func restore_filter(button_flags: Array[bool]):
var index: int = 0
for flag: bool in button_flags:
var btn: Button = filter_box.get_child(index)
btn.set_pressed_no_signal(flag)
index += 1
func set_outline_order(new_outline_order: PackedStringArray):
outline_order = new_outline_order
if (filter_box == null):
return
outline_type_order.sort_custom(sort_types_by_outline_order)
update_outline_button_order()
update_outline()
func set_hide_private_members(new_value: bool):
is_hide_private_members = new_value
if (filter_box == null):
return
update_outline_cache()
update_outline()
func update_filter_buttons():
# Update filter buttons.
for btn_node: Node in filter_box.get_children():
var btn: Button = btn_node
var property: StringName = btn.get_meta(PROPERTY)
btn.button_pressed = plugin.get_setting(property, btn.button_pressed)
func create_function_signature(method: Dictionary) -> String:
var func_name: String = method[&"name"]
func_name += "("
var args: Array = method[&"args"]
var default_args: Array = method[&"default_args"]
var arg_index: int = 0
var default_arg_index: int = 0
var arg_str: String = ""
for arg: Dictionary in args:
if (arg_str != ""):
arg_str += ", "
arg_str += arg[&"name"]
var type: String = get_type(arg)
if (type != ""):
arg_str += ": " + type
if (args.size() - arg_index <= default_args.size()):
var default_arg: Variant = default_args[default_arg_index]
if (!default_arg):
var type_hint: int = arg[&"type"]
if (is_dictionary(type_hint)):
default_arg = {}
elif (is_array(type_hint)):
default_arg = []
arg_str += " = " + var_to_str(default_arg)
default_arg_index += 1
arg_index += 1
func_name += arg_str + ")"
var return_str: String = get_type(method[&"return"])
if (return_str == ""):
return func_name
func_name += " -> " + return_str
return func_name
func get_type(dict: Dictionary) -> String:
var type: String = dict[&"class_name"]
if (type != &""):
if (type.begins_with(&"res://")):
type = type.substr(type.rfind(&".") + 1)
return type
var type_hint: int = dict[&"type"]
if (type_hint == 0):
return &""
type = type_string(type_hint)
if (is_dictionary(type_hint)):
var generic: String = dict[&"hint_string"]
if (generic != &""):
var generic_parts: PackedStringArray = generic.split(";")
if (generic_parts.size() == 2):
return type + "[" + generic_parts[0] + ", " + generic_parts[1] + "]"
if (is_array(type_hint)):
var generic: String = dict[&"hint_string"]
if (generic != &""):
return type + "[" + generic + "]"
return type
func is_dictionary(type_hint: int) -> bool:
return type_hint == 27
func is_array(type_hint: int) -> bool:
return type_hint == 28
func reset_icons():
init_icons()
engine_func_btn.icon = engine_func_icon
func_btn.icon = func_icon
signal_btn.icon = signal_icon
export_btn.icon = export_icon
property_btn.icon = property_icon
class_btn.icon = class_icon
constant_btn.icon = constant_icon
update_outline()
func create_editor_texture(texture: Texture2D) -> Texture2D:
var image: Image = texture.get_image().duplicate()
image.adjust_bcs(1.0, 1.0, get_editor_icon_saturation())
return ImageTexture.create_from_image(image)
func load_rel(path: String) -> Variant:
var script_path: String = get_script().get_path().get_base_dir()
return load(script_path.path_join(path))
func is_sorted() -> bool:
return EditorInterface.get_editor_settings().get_setting("text_editor/script_list/sort_members_outline_alphabetically")
func get_editor_icon_saturation() -> float:
return EditorInterface.get_editor_settings().get_setting("interface/theme/icon_saturation")
## Cache for everything inside we collected to show in the Outline.
class OutlineCache:
var classes: Array[String] = []
var constants: Array[String] = []
var signals: Array[String] = []
var exports: Array[String] = []
var properties: Array[String] = []
var funcs: Array[String] = []
var engine_funcs: Array[String] = []
## Outline type for a concrete button with their items in the Outline.
class OutlineType:
var type_name: StringName
var add_to_outline: Callable
@@ -0,0 +1 @@
uid://db0be00ai3tfi
@@ -0,0 +1,22 @@
[gd_scene format=3 uid="uid://ux3ldi4ka8ji"]
[ext_resource type="Script" uid="uid://db0be00ai3tfi" path="res://addons/script-ide/outline/outline_container.gd" id="1_w4vhe"]
[node name="OutlineContainer" type="VBoxContainer" unique_id=181236283]
offset_right = 174.0
offset_bottom = 253.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_w4vhe")
[node name="FilterBox" type="HBoxContainer" parent="." unique_id=1653721963]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/separation = 2
[node name="Outline" type="ItemList" parent="." unique_id=160258583]
unique_name_in_owner = true
auto_translate_mode = 2
layout_mode = 2
size_flags_vertical = 3
allow_reselect = true
@@ -0,0 +1,272 @@
## The override panel does show all functions that come from the super class (extends)
## that can be overridden by the script this is called on.
@tool
extends PopupPanel
const FUNC_META: StringName = &"func"
const Plugin := preload("uid://bc0b5v66xdidn")
const OutlineContainer := preload("uid://db0be00ai3tfi")
@onready var filter_txt: LineEdit = %FilterTxt
@onready var class_func_tree: Tree = %ClassFuncTree
@onready var ok_btn: Button = %OkBtn
@onready var cancel_btn: Button = %CancelBtn
var plugin: Plugin
var outline_container: OutlineContainer
var selections: Dictionary[String, bool] = {} # Used as Set.
var class_to_functions: Dictionary[StringName, PackedStringArray]
func _ready() -> void:
filter_txt.text_changed.connect(update_tree_filter.unbind(1))
class_func_tree.multi_selected.connect(func(item: TreeItem, col: int, selected: bool): save_selection(selected, item))
class_func_tree.item_activated.connect(generate_functions)
cancel_btn.pressed.connect(hide)
ok_btn.pressed.connect(generate_functions)
about_to_popup.connect(on_show)
filter_txt.gui_input.connect(navigate_on_tree)
func navigate_on_tree(event: InputEvent):
if (event.is_action_pressed(&"ui_select", true)):
var selected: TreeItem = get_selected_tree_item()
if (selected == null):
return
class_func_tree.accept_event()
if (!selected.is_selectable(0)):
selected.collapsed = !selected.collapsed
return
if (selected.is_selected(0)):
selected.deselect(0)
save_selection(false, selected)
else:
selected.select(0)
save_selection(true, selected)
elif (event.is_action_pressed(&"ui_text_submit", true)):
class_func_tree.accept_event()
if (selections.size() == 0):
return
generate_functions()
elif (event.is_action_pressed(&"ui_down", true)):
var selected: TreeItem = get_selected_tree_item()
if (selected == null):
return
var item: TreeItem = selected.get_next_in_tree()
if (item == null):
return
focus_tree_item(item)
elif (event.is_action_pressed(&"ui_up", true)):
var selected: TreeItem = get_selected_tree_item()
if (selected == null):
return
var item: TreeItem = selected.get_prev_in_tree()
if (item == null):
return
focus_tree_item(item)
elif (event.is_action_pressed(&"ui_page_down", true)):
var selected: TreeItem = get_selected_tree_item()
if (selected == null):
return
var item: TreeItem = selected.get_next_in_tree()
if (item == null):
return
for index: int in 4:
var next: TreeItem = item.get_next_in_tree()
if (next == null):
break
item = next
focus_tree_item(item)
elif (event.is_action_pressed(&"ui_page_up", true)):
var selected: TreeItem = get_selected_tree_item()
if (selected == null):
return
var item: TreeItem = selected.get_prev_in_tree()
if (item == null):
return
for index: int in 4:
var prev: TreeItem = item.get_prev_in_tree()
if (prev == null):
break
item = prev
focus_tree_item(item)
func get_selected_tree_item() -> TreeItem:
var selected: TreeItem = class_func_tree.get_selected()
if (selected == null):
selected = class_func_tree.get_root()
return selected
func focus_tree_item(item: TreeItem):
var was_selected: bool = item.is_selected(0)
item.select(0)
item.deselect(0)
if (was_selected):
item.select(0)
class_func_tree.ensure_cursor_is_visible()
class_func_tree.accept_event()
func update_tree_filter():
update_tree()
func save_selection(selected: bool, item: TreeItem):
if (selected):
selections[item.get_text(0)] = true
else:
selections.erase(item.get_text(0))
ok_btn.disabled = selections.size() == 0
func on_show():
class_func_tree.clear()
selections.clear()
ok_btn.disabled = true
filter_txt.text = &""
var script: Script = EditorInterface.get_script_editor().get_current_script()
class_to_functions = collect_all_class_functions(script)
if (class_to_functions.is_empty()):
return
update_tree()
filter_txt.grab_focus()
func update_tree():
class_func_tree.clear()
var text: String = filter_txt.text
var root: TreeItem = class_func_tree.create_item()
for class_name_str: StringName in class_to_functions.keys():
var class_item: TreeItem = root.create_child(0)
class_item.set_selectable(0, false)
class_item.set_text(0, class_name_str)
for function: String in class_to_functions.get(class_name_str):
var is_preselected: bool = selections.has(function)
if (is_preselected || text.is_empty() || text.is_subsequence_ofn(function)):
var func_item: TreeItem = class_item.create_child()
func_item.set_text(0, function)
if (plugin.keywords.has(function.get_slice("(", 0))):
func_item.set_icon(0, outline_container.engine_func_icon)
else:
func_item.set_icon(0, outline_container.func_icon)
if (is_preselected):
func_item.select(0)
func collect_all_class_functions(script: Script) -> Dictionary[StringName, PackedStringArray]:
var existing_funcs: Dictionary[String, bool] = {} # Used as Set.
for func_str: String in outline_container.outline_cache.engine_funcs:
existing_funcs[func_str] = true
for func_str: String in outline_container.outline_cache.funcs:
existing_funcs[func_str] = true
var class_to_functions: Dictionary[StringName, PackedStringArray] = collect_super_class_functions(script.get_base_script(), existing_funcs)
var native_class_to_functions: Dictionary[StringName, PackedStringArray] = collect_native_class_functions(script.get_instance_base_type(), existing_funcs)
return native_class_to_functions.merged(class_to_functions)
func collect_super_class_functions(base_script: Script, existing_funcs: Dictionary[String, bool]) -> Dictionary[StringName, PackedStringArray]:
var super_classes: Array[Script] = []
while (base_script != null):
super_classes.insert(0, base_script)
base_script = base_script.get_base_script()
var class_to_functions: Dictionary[StringName, PackedStringArray] = {}
for super_class: Script in super_classes:
var functions: PackedStringArray = collect_script_functions(super_class, existing_funcs)
if (functions.is_empty()):
continue
class_to_functions[super_class.get_global_name()] = functions
return class_to_functions
func collect_native_class_functions(native_class: StringName, existing_funcs: Dictionary[String, bool]) -> Dictionary[StringName, PackedStringArray]:
var super_native_classes: Array[StringName] = []
while (native_class != &""):
super_native_classes.insert(0, native_class)
native_class = ClassDB.get_parent_class(native_class)
var class_to_functions: Dictionary[StringName, PackedStringArray] = {}
for super_native_class: StringName in super_native_classes:
var functions: PackedStringArray = collect_class_functions(super_native_class, existing_funcs)
if (functions.is_empty()):
continue
class_to_functions[super_native_class] = functions
return class_to_functions
func collect_class_functions(native_class: StringName, existing_funcs: Dictionary[String, bool]) -> PackedStringArray:
var functions: PackedStringArray = []
for method: Dictionary in ClassDB.class_get_method_list(native_class, true):
if (method[&"flags"] & METHOD_FLAG_VIRTUAL <= 0):
continue
var func_name: String = method[&"name"]
if (existing_funcs.has(func_name)):
continue
func_name = outline_container.create_function_signature(method)
functions.append(func_name)
return functions
func collect_script_functions(super_class: Script, existing_funcs: Dictionary[String, bool]) -> PackedStringArray:
var functions: PackedStringArray = []
for method: Dictionary in super_class.get_script_method_list():
var func_name: String = method[&"name"]
if (existing_funcs.has(func_name)):
continue
existing_funcs[func_name] = true
func_name = outline_container.create_function_signature(method)
functions.append(func_name)
return functions
func generate_functions():
if (selections.size() == 0):
return
var generated_text: String = ""
for function: String in selections.keys():
if (function.ends_with(")")):
function = function + " -> void"
generated_text += "\nfunc " + function + ":\n\tpass\n"
var editor: CodeEdit = EditorInterface.get_script_editor().get_current_editor().get_base_editor()
editor.text += generated_text
plugin.goto_line(editor.get_line_count() - 1)
# Deferred as otherwise we get weird errors in the console.
# Probably due to this beeing called in a signal and auto unparent is true.
# 100% Engine bug or at least weird behavior.
hide.call_deferred()
@@ -0,0 +1 @@
uid://c4w55j4jswg2t
@@ -0,0 +1,60 @@
[gd_scene format=3 uid="uid://bb1n82qxlqanh"]
[ext_resource type="Script" uid="uid://c4w55j4jswg2t" path="res://addons/script-ide/override/override_popup.gd" id="1_54se3"]
[node name="OverridePanel" type="PopupPanel" unique_id=145780904]
oversampling_override = 1.0
size = Vector2i(317, 122)
visible = true
script = ExtResource("1_54se3")
[node name="PanelContainer" type="PanelContainer" parent="." unique_id=1028771242]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 4.0
offset_top = 4.0
offset_right = -4.0
offset_bottom = -4.0
grow_horizontal = 2
grow_vertical = 2
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer" unique_id=701240329]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer" unique_id=46770551]
layout_mode = 2
theme_override_constants/separation = 4
[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer" unique_id=927995895]
layout_mode = 2
text = "Select Functions to Override/Implement"
[node name="FilterTxt" type="LineEdit" parent="PanelContainer/MarginContainer/VBoxContainer" unique_id=759695003]
unique_name_in_owner = true
layout_mode = 2
placeholder_text = "Filter Methods"
[node name="ClassFuncTree" type="Tree" parent="PanelContainer/MarginContainer/VBoxContainer" unique_id=1883825598]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
hide_root = true
select_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer" unique_id=1036676649]
layout_mode = 2
theme_override_constants/separation = 4
alignment = 2
[node name="OkBtn" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer" unique_id=598122006]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 0)
layout_mode = 2
text = "Ok"
[node name="CancelBtn" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer" unique_id=1978369329]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 0)
layout_mode = 2
text = "Cancel"
+7
View File
@@ -0,0 +1,7 @@
[plugin]
name="Script-IDE"
description="Transforms the Script UI into an IDE like UI. Tabs are used for navigating between scripts. The default Outline got an overhaul and now shows all members of the script (not just methods) with unique icons for faster navigation. Enhanced keyboard navigation for Scripts and Outline. Fast quick search functionality."
author="Marius Hanl"
version="2.2.5"
script="plugin.gd"
+940
View File
@@ -0,0 +1,940 @@
## Copyright (c) 2023-present Marius Hanl under the MIT License.
## The editor plugin entrypoint for Script-IDE.
##
## Some features interfere with the editor code that is inside 'script_editor_plugin.cpp'.
## That is, the original structure is changed by this plugin, in order to support everything.
## The internals of the native C++ code are therefore important in order to make this plugin work
## without interfering with the Engine itself (and their Node's).
##
## Script-IDE does not use global class_name's in order to not clutter projects using it.
## Especially since this is an editor only plugin, we do not want this plugin in the final game.
## Therefore, components that references the plugin is untyped.
@tool
extends EditorPlugin
const BUILT_IN_SCRIPT: StringName = &"::GDScript"
const QUICK_OPEN_INTERVAL: float = 400.0
const MULTILINE_TAB_BAR: PackedScene = preload("uid://vjuhunm2uboy")
const MultilineTabBar := preload("uid://l1rdargfn67o")
const QUICK_OPEN_SCENE: PackedScene = preload("uid://d2pttchmj3n7q")
const QuickOpenPopup := preload("uid://cgwp4rl1udqbb")
const OVERRIDE_SCENE: PackedScene = preload("uid://bb1n82qxlqanh")
const OverridePopup := preload("uid://c4w55j4jswg2t")
const OUTLINE_CONTAINER_SCENE: PackedScene = preload("uid://ux3ldi4ka8ji")
const OutlineContainer := preload("uid://db0be00ai3tfi")
const SplitCodeEdit := preload("uid://boy48rhhyrph")
#region Settings and Shortcuts
## Editor setting path
const SCRIPT_IDE: StringName = &"plugin/script_ide/"
## Editor setting for the outline position
const OUTLINE_POSITION_RIGHT: StringName = SCRIPT_IDE + &"outline_position_right"
## Editor setting to control the order of the outline
const OUTLINE_ORDER: StringName = SCRIPT_IDE + &"outline_order"
## Editor setting to control whether private members (annotated with '_' should be hidden or not)
const HIDE_PRIVATE_MEMBERS: StringName = SCRIPT_IDE + &"hide_private_members"
## Editor setting to control whether we want to auto navigate to the script
## in the filesystem (dock) when selected
const AUTO_NAVIGATE_IN_FS: StringName = SCRIPT_IDE + &"auto_navigate_in_filesystem_dock"
## Editor setting to control whether the script list should be visible or not
const SCRIPT_LIST_VISIBLE: StringName = SCRIPT_IDE + &"script_list_visible"
## Editor setting to control whether the script tabs should be visible or not.
const SCRIPT_TABS_VISIBLE: StringName = SCRIPT_IDE + &"script_tabs_visible"
## Editor setting to control where the script tabs should be.
const SCRIPT_TABS_POSITION_TOP: StringName = SCRIPT_IDE + &"script_tabs_position_top"
## Editor setting to control if all script tabs should have close button.
const SCRIPT_TABS_CLOSE_BUTTON_ALWAYS: StringName = SCRIPT_IDE + &"script_tabs_close_button_always"
## Editor setting to control if all tabs should be shown in a single line.
const SCRIPT_TABS_SINGLELINE: StringName = SCRIPT_IDE + &"script_tabs_singleline"
## Editor setting for the 'Open Outline Popup' shortcut
const OPEN_OUTLINE_POPUP: StringName = SCRIPT_IDE + &"open_outline_popup"
## Editor setting for the 'Open Scripts Popup' shortcut
const OPEN_SCRIPTS_POPUP: StringName = SCRIPT_IDE + &"open_scripts_popup"
## Editor setting for the 'Open Override Popup' shortcut
const OPEN_OVERRIDE_POPUP: StringName = SCRIPT_IDE + &"open_override_popup"
## Editor setting for the 'Tab cycle forward' shortcut
const TAB_CYCLE_FORWARD: StringName = SCRIPT_IDE + &"tab_cycle_forward"
## Editor setting for the 'Tab cycle backward' shortcut
const TAB_CYCLE_BACKWARD: StringName = SCRIPT_IDE + &"tab_cycle_backward"
## Editor setting for the 'Open Quick Search Popup (All)' shortcut
const OPEN_QUICK_SEARCH_POPUP: StringName = SCRIPT_IDE + &"open_quick_search_popup"
## Editor setting for the 'Open Quick Search Popup (Scenes)' shortcut
const OPEN_QUICK_SEARCH_POPUP_SCENES: StringName = SCRIPT_IDE + &"open_quick_search_popup_scenes"
## Editor setting for the 'Open Quick Search Popup (Scripts)' shortcut
const OPEN_QUICK_SEARCH_POPUP_GDSCRIPTS: StringName = SCRIPT_IDE + &"open_quick_search_popup_scripts"
## Editor setting for the 'Open Quick Search Popup (Resources)' shortcut
const OPEN_QUICK_SEARCH_POPUP_RESOURCES: StringName = SCRIPT_IDE + &"open_quick_search_popup_resources"
## Engine editor setting for the icon saturation, so our icons can react.
const ICON_SATURATION: StringName = &"interface/theme/icon_saturation"
## Engine editor setting for the show members functionality.
const SHOW_MEMBERS: StringName = &"text_editor/script_list/show_members_overview"
## Engine editor setting if monospace font should be used for the outline.
const MONOSPACE_OUTLINE: StringName = &"interface/theme/use_monospace_font_for_editor_symbols"
## We track the user setting, so we can restore it properly.
var show_members: bool = true
#endregion
#region Editor settings
var is_outline_right: bool = true
var is_script_tabs_top: bool = true
var is_auto_navigate_in_fs: bool = true
var is_script_list_visible: bool = false
var open_outline_popup_shc: Shortcut
var open_scripts_popup_shc: Shortcut
var open_quick_search_popup_shc: Shortcut
var open_quick_search_popup_scenes_shc: Shortcut
var open_quick_search_popup_gdscripts_shc: Shortcut
var open_quick_search_popup_resources_shc: Shortcut
var open_override_popup_shc: Shortcut
var tab_cycle_forward_shc: Shortcut
var tab_cycle_backward_shc: Shortcut
#endregion
#region Existing Engine controls we modify
var script_editor_split_container: HSplitContainer
var files_panel: Control
var old_scripts_tab_container: TabContainer
var old_scripts_tab_bar: TabBar
var script_filter_txt: LineEdit
var scripts_item_list: ItemList
var script_panel_split_container: VSplitContainer
var old_outline: Control
var outline_filter_txt: LineEdit
var sort_btn: Button
#endregion
#region Own controls we add
var outline_container: OutlineContainer
var outline_popup: PopupPanel
var multiline_tab_bar: MultilineTabBar
var scripts_popup: PopupPanel
var quick_open_popup: QuickOpenPopup
var override_popup: OverridePopup
var tab_splitter: HSplitContainer
#endregion
#region Plugin variables
var keywords: Dictionary[String, bool] = {} # Used as Set.
var old_script_editor_base: ScriptEditorBase
var old_script_type: StringName
var is_script_changed: bool = false
var file_to_navigate: String = &""
var quick_open_tween: Tween
var suppress_settings_sync: bool = false
#endregion
#region Plugin Enter / Exit setup
## Change the Engine script UI and transform into an IDE like UI
func _enter_tree() -> void:
init_settings()
init_shortcuts()
setup_change_listener()
# --- Files Panel - Start --- #
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
script_editor_split_container = find_or_null(script_editor.find_children("*", "HSplitContainer", true, false))
files_panel = script_editor_split_container.get_child(0)
# The 'Filter Scripts' Panel
var upper_files_panel: Control = files_panel.get_child(0)
# The 'Filter Methods' Panel
var lower_files_panel: Control = files_panel.get_child(1)
# Change script item list visibility (based on settings).
scripts_item_list = find_or_null(upper_files_panel.find_children("*", "ItemList", true, false))
scripts_item_list.allow_reselect = true
scripts_item_list.item_selected.connect(hide_scripts_popup.unbind(1))
update_script_list_visibility()
# Add script filter navigation.
script_filter_txt = find_or_null(scripts_item_list.get_parent().find_children("*", "LineEdit", true, false))
script_filter_txt.gui_input.connect(navigate_on_list.bind(scripts_item_list, select_script))
# --- Files Panel - End --- #
# --- Outline - Start --- #
var item_lists: Array[Node] = lower_files_panel.find_children("*", "ItemList", true, false)
if (item_lists.is_empty()):
# Godot >= 4.8.dev4, outline is a Tree now.
old_outline = find_or_null(lower_files_panel.find_children("*", "Tree", true, false))
else:
old_outline = find_or_null(item_lists)
lower_files_panel.remove_child(old_outline)
outline_container = OUTLINE_CONTAINER_SCENE.instantiate()
outline_container.plugin = self
# Add navigation to the filter and text filtering.
outline_filter_txt = find_or_null(lower_files_panel.find_children("*", "LineEdit", true, false))
outline_filter_txt.gui_input.connect(navigate_in_outline)
outline_filter_txt.text_changed.connect(update_outline.unbind(1))
outline_container.outline_filter_txt = outline_filter_txt
lower_files_panel.add_child(outline_container)
# Add callback when the sorting changed.
sort_btn = find_or_null(lower_files_panel.find_children("*", "Button", true, false))
sort_btn.pressed.connect(update_outline)
outline_container.is_hide_private_members = get_setting(HIDE_PRIVATE_MEMBERS, outline_container.is_hide_private_members)
outline_container.outline_order = get_outline_order()
update_outline_font()
update_outline_position()
# --- Outline - End --- #
# --- Tabs - Start --- #
old_scripts_tab_container = find_or_null(script_editor.find_children("*", "TabContainer", true, false))
old_scripts_tab_bar = old_scripts_tab_container.get_tab_bar()
old_scripts_tab_bar.tab_changed.connect(on_tab_changed)
var tab_container_parent: Control = old_scripts_tab_container.get_parent()
tab_splitter = HSplitContainer.new()
tab_splitter.size_flags_horizontal = Control.SIZE_EXPAND_FILL
tab_splitter.size_flags_vertical = Control.SIZE_EXPAND_FILL
tab_container_parent.add_child(tab_splitter)
tab_container_parent.move_child(tab_splitter, 0)
old_scripts_tab_container.reparent(tab_splitter)
# When something changed, we need to sync our own tab container.
old_scripts_tab_container.child_order_changed.connect(notify_order_changed)
multiline_tab_bar = MULTILINE_TAB_BAR.instantiate()
multiline_tab_bar.plugin = self
multiline_tab_bar.scripts_item_list = scripts_item_list
multiline_tab_bar.script_filter_txt = script_filter_txt
multiline_tab_bar.scripts_tab_container = old_scripts_tab_container
tab_container_parent.add_theme_constant_override(&"separation", 0)
tab_container_parent.add_child(multiline_tab_bar)
multiline_tab_bar.split_toggled.connect(toggle_split_view)
multiline_tab_bar.show_close_button_always = get_setting(SCRIPT_TABS_CLOSE_BUTTON_ALWAYS, multiline_tab_bar.show_close_button_always)
multiline_tab_bar.is_singleline_tabs = get_setting(SCRIPT_TABS_SINGLELINE, multiline_tab_bar.is_singleline_tabs)
multiline_tab_bar.visible = get_setting(SCRIPT_TABS_VISIBLE, true)
update_tabs_position()
# Create and set script popup.
script_panel_split_container = scripts_item_list.get_parent().get_parent()
create_set_scripts_popup()
# --- Tabs - End --- #
on_tab_changed(old_scripts_tab_bar.current_tab)
## Restore the old Engine script UI and free everything we created
func _exit_tree() -> void:
var file_system: EditorFileSystem = EditorInterface.get_resource_filesystem()
file_system.filesystem_changed.disconnect(schedule_update)
get_editor_settings().settings_changed.disconnect(sync_settings)
if (tab_splitter != null):
var tab_container_parent: Control = tab_splitter.get_parent()
old_scripts_tab_container.reparent(tab_container_parent)
tab_container_parent.move_child(old_scripts_tab_container, 1)
tab_splitter.free()
if (script_editor_split_container != null):
if (script_editor_split_container != files_panel.get_parent()):
script_editor_split_container.add_child(files_panel)
# Try to restore the previous split offset.
if (is_outline_right):
var split_offset: float = script_editor_split_container.get_child(1).size.x
script_editor_split_container.split_offset = split_offset
script_editor_split_container.move_child(files_panel, 0)
outline_filter_txt.gui_input.disconnect(navigate_in_outline)
outline_filter_txt.text_changed.disconnect(update_outline)
sort_btn.pressed.disconnect(update_outline)
var outline_parent: Control = outline_container.get_parent()
outline_parent.remove_child(outline_container)
outline_parent.add_child(old_outline)
outline_parent.move_child(old_outline, outline_filter_txt.get_index() + 1)
outline_container.free()
if (old_scripts_tab_bar != null):
old_scripts_tab_bar.tab_changed.disconnect(on_tab_changed)
if (old_scripts_tab_container != null):
old_scripts_tab_container.child_order_changed.disconnect(notify_order_changed)
old_scripts_tab_container.get_parent().remove_theme_constant_override(&"separation")
old_scripts_tab_container.get_parent().remove_child(multiline_tab_bar)
if (multiline_tab_bar != null):
multiline_tab_bar.free_tabs()
multiline_tab_bar.free()
scripts_popup.free()
if (scripts_item_list != null):
scripts_item_list.allow_reselect = false
scripts_item_list.item_selected.disconnect(hide_scripts_popup)
scripts_item_list.get_parent().visible = true
if (script_filter_txt != null):
script_filter_txt.gui_input.disconnect(navigate_on_list)
if (outline_popup != null):
outline_popup.free()
if (quick_open_popup != null):
quick_open_popup.free()
if (override_popup != null):
override_popup.free()
if (!show_members):
set_setting(SHOW_MEMBERS, show_members)
func _set_window_layout(configuration: ConfigFile):
script_editor_split_container.split_offset = configuration.get_value("ScriptEditor", "script_split_offset", 200)
#endregion
#region Plugin and Shortcut processing
## Lazy pattern to update the editor only once per frame
func _process(delta: float) -> void:
update_editor()
set_process(false)
## Process the user defined shortcuts
func _shortcut_input(event: InputEvent) -> void:
if (!event.is_pressed() || event.is_echo()):
return
if (open_outline_popup_shc.matches_event(event)):
get_viewport().set_input_as_handled()
open_outline_popup()
elif (open_scripts_popup_shc.matches_event(event)):
get_viewport().set_input_as_handled()
open_scripts_popup()
elif (open_quick_search_popup_shc.matches_event(event)):
if (quick_open_tween != null && quick_open_tween.is_running()):
get_viewport().set_input_as_handled()
if (quick_open_tween != null):
quick_open_tween.kill()
quick_open_tween = create_tween()
quick_open_tween.tween_interval(0.2)
quick_open_tween.tween_callback(open_quick_search_popup)
quick_open_tween.tween_callback(func(): quick_open_tween = null)
else:
quick_open_tween = create_tween()
quick_open_tween.tween_interval(QUICK_OPEN_INTERVAL / 1000.0)
quick_open_tween.tween_callback(func(): quick_open_tween = null)
elif (open_override_popup_shc.matches_event(event)):
get_viewport().set_input_as_handled()
open_override_popup()
elif (open_quick_search_popup_scenes_shc.matches_event(event)):
open_quick_search_popup(QuickOpenPopup.Category.SCENES)
elif (open_quick_search_popup_gdscripts_shc.matches_event(event)):
open_quick_search_popup(QuickOpenPopup.Category.GDSCRIPTS)
elif (open_quick_search_popup_resources_shc.matches_event(event)):
open_quick_search_popup(QuickOpenPopup.Category.RESOURCES)
## May cancels the quick search shortcut timer.
func _input(event: InputEvent) -> void:
if (event is InputEventKey):
if (!open_quick_search_popup_shc.matches_event(event)):
if (quick_open_tween != null):
quick_open_tween.kill()
quick_open_tween = null
#endregion
#region Settings and Shortcut initialization
## Setups the listener (connect) to the properties we need to react to.
func setup_change_listener():
# Update on filesystem changed (e.g. save operation).
var file_system: EditorFileSystem = EditorInterface.get_resource_filesystem()
file_system.filesystem_changed.connect(schedule_update)
# Sync settings changes for this plugin.
get_editor_settings().settings_changed.connect(sync_settings)
## Initializes all settings.
## Every setting can be changed while this plugin is active, which will override them.
func init_settings():
is_script_list_visible = get_setting(SCRIPT_LIST_VISIBLE, is_script_list_visible)
is_script_tabs_top = get_setting(SCRIPT_TABS_POSITION_TOP, is_script_tabs_top)
is_outline_right = get_setting(OUTLINE_POSITION_RIGHT, is_outline_right)
is_auto_navigate_in_fs = get_setting(AUTO_NAVIGATE_IN_FS, is_auto_navigate_in_fs)
# Users may disabled this, but with this plugin, we want to show the new Outline.
# So we need to reenable it, but restore the old value on exit.
show_members = get_setting(SHOW_MEMBERS, true)
if (!show_members):
set_setting(SHOW_MEMBERS, true)
## Initializes all shortcuts.
## Every shortcut can be changed while this plugin is active, which will override them.
func init_shortcuts():
var editor_settings: EditorSettings = get_editor_settings()
if (!editor_settings.has_setting(OPEN_OUTLINE_POPUP)):
var shortcut: Shortcut = Shortcut.new()
var event: InputEventKey = InputEventKey.new()
event.device = -1
event.command_or_control_autoremap = true
event.keycode = KEY_O
shortcut.events = [ event ]
editor_settings.set_setting(OPEN_OUTLINE_POPUP, shortcut)
if (!editor_settings.has_setting(OPEN_SCRIPTS_POPUP)):
var shortcut: Shortcut = Shortcut.new()
var event: InputEventKey = InputEventKey.new()
event.device = -1
event.command_or_control_autoremap = true
event.keycode = KEY_U
shortcut.events = [ event ]
editor_settings.set_setting(OPEN_SCRIPTS_POPUP, shortcut)
if (!editor_settings.has_setting(OPEN_QUICK_SEARCH_POPUP)):
var shortcut: Shortcut = Shortcut.new()
var event: InputEventKey = InputEventKey.new()
event.device = -1
event.keycode = KEY_SHIFT
shortcut.events = [ event ]
editor_settings.set_setting(OPEN_QUICK_SEARCH_POPUP, shortcut)
if (!editor_settings.has_setting(OPEN_QUICK_SEARCH_POPUP_SCENES)):
var shortcut: Shortcut = Shortcut.new()
var event: InputEventKey = InputEventKey.new()
event.device = -1
event.command_or_control_autoremap = true
event.keycode = KEY_N
shortcut.events = [ event ]
editor_settings.set_setting(OPEN_QUICK_SEARCH_POPUP_SCENES, shortcut)
if (!editor_settings.has_setting(OPEN_QUICK_SEARCH_POPUP_GDSCRIPTS)):
var shortcut: Shortcut = Shortcut.new()
var event: InputEventKey = InputEventKey.new()
event.device = -1
event.command_or_control_autoremap = true
event.shift_pressed = true
event.keycode = KEY_N
shortcut.events = [ event ]
editor_settings.set_setting(OPEN_QUICK_SEARCH_POPUP_GDSCRIPTS, shortcut)
if (!editor_settings.has_setting(OPEN_QUICK_SEARCH_POPUP_RESOURCES)):
var shortcut: Shortcut = Shortcut.new()
var event: InputEventKey = InputEventKey.new()
event.device = -1
event.command_or_control_autoremap = true
event.alt_pressed = true
event.shift_pressed = true
event.keycode = KEY_N
shortcut.events = [ event ]
editor_settings.set_setting(OPEN_QUICK_SEARCH_POPUP_RESOURCES, shortcut)
if (!editor_settings.has_setting(OPEN_OVERRIDE_POPUP)):
var shortcut: Shortcut = Shortcut.new()
var event: InputEventKey = InputEventKey.new()
event.device = -1
event.keycode = KEY_INSERT
event.alt_pressed = true
shortcut.events = [ event ]
editor_settings.set_setting(OPEN_OVERRIDE_POPUP, shortcut)
if (!editor_settings.has_setting(TAB_CYCLE_FORWARD)):
var shortcut: Shortcut = Shortcut.new()
var event: InputEventKey = InputEventKey.new()
event.device = -1
event.keycode = KEY_TAB
event.ctrl_pressed = true
shortcut.events = [ event ]
editor_settings.set_setting(TAB_CYCLE_FORWARD, shortcut)
if (!editor_settings.has_setting(TAB_CYCLE_BACKWARD)):
var shortcut: Shortcut = Shortcut.new()
var event: InputEventKey = InputEventKey.new()
event.device = -1
event.keycode = KEY_TAB
event.shift_pressed = true
event.ctrl_pressed = true
shortcut.events = [ event ]
editor_settings.set_setting(TAB_CYCLE_BACKWARD, shortcut)
open_outline_popup_shc = editor_settings.get_setting(OPEN_OUTLINE_POPUP)
open_scripts_popup_shc = editor_settings.get_setting(OPEN_SCRIPTS_POPUP)
open_quick_search_popup_shc = editor_settings.get_setting(OPEN_QUICK_SEARCH_POPUP)
open_quick_search_popup_scenes_shc = editor_settings.get_setting(OPEN_QUICK_SEARCH_POPUP_SCENES)
open_quick_search_popup_gdscripts_shc = editor_settings.get_setting(OPEN_QUICK_SEARCH_POPUP_GDSCRIPTS)
open_quick_search_popup_resources_shc = editor_settings.get_setting(OPEN_QUICK_SEARCH_POPUP_RESOURCES)
open_override_popup_shc = editor_settings.get_setting(OPEN_OVERRIDE_POPUP)
tab_cycle_forward_shc = editor_settings.get_setting(TAB_CYCLE_FORWARD)
tab_cycle_backward_shc = editor_settings.get_setting(TAB_CYCLE_BACKWARD)
#endregion
## Schedules an update on the next frame.
func schedule_update():
set_process(true)
## Updates all parts of the editor that are needed to be synchronized with the file system change.
func update_editor():
if (file_to_navigate != &""):
EditorInterface.select_file(file_to_navigate)
EditorInterface.get_script_editor().get_current_editor().get_base_editor().grab_focus()
file_to_navigate = &""
update_keywords()
if (is_script_changed):
multiline_tab_bar.tab_changed()
outline_container.tab_changed()
is_script_changed = false
else:
# We saved / filesystem changed. so need to update everything.
multiline_tab_bar.update_tabs()
outline_container.update()
func on_tab_changed(index: int):
if (old_script_editor_base != null):
old_script_editor_base.edited_script_changed.disconnect(update_selected_tab)
old_script_editor_base = null
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
var script_editor_base: ScriptEditorBase = script_editor.get_current_editor()
if (script_editor_base != null):
script_editor_base.edited_script_changed.connect(update_selected_tab)
old_script_editor_base = script_editor_base
if (!multiline_tab_bar.is_split()):
multiline_tab_bar.set_split_disabled(script_editor_base == null)
is_script_changed = true
if (is_auto_navigate_in_fs && script_editor.get_current_script() != null):
var file: String = script_editor.get_current_script().get_path()
if (file.contains(BUILT_IN_SCRIPT)):
# We navigate to the scene in case of a built-in script.
file = file.get_slice(BUILT_IN_SCRIPT, 0)
file_to_navigate = file
else:
file_to_navigate = &""
schedule_update()
func toggle_split_view():
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
var split_script_editor_base: ScriptEditorBase = script_editor.get_current_editor()
if (!multiline_tab_bar.is_split()):
if (split_script_editor_base == null):
return
var base_editor: Control = split_script_editor_base.get_base_editor()
if !(base_editor is CodeEdit):
return
multiline_tab_bar.set_split(true)
var editor: CodeEdit = SplitCodeEdit.new_from(base_editor)
var container: PanelContainer = PanelContainer.new()
container.custom_minimum_size.x = 200
container.size_flags_horizontal = Control.SIZE_EXPAND_FILL
container.add_child(editor)
tab_splitter.add_child(container)
else:
multiline_tab_bar.set_split(false)
tab_splitter.remove_child(tab_splitter.get_child(tab_splitter.get_child_count() - 1))
if (split_script_editor_base == null):
multiline_tab_bar.set_split_disabled(true)
func navigate_in_outline(event: InputEvent):
navigate_on_list(event, outline_container.outline, outline_container.find_in_outline_and_goto)
func notify_order_changed():
multiline_tab_bar.script_order_changed()
func open_quick_search_popup(category: QuickOpenPopup.Category = QuickOpenPopup.Category.ALL):
var pref_size: Vector2
if (quick_open_popup == null):
quick_open_popup = QUICK_OPEN_SCENE.instantiate()
quick_open_popup.plugin = self
quick_open_popup.set_unparent_when_invisible(true)
pref_size = Vector2(500, 400) * get_editor_scale()
else:
pref_size = quick_open_popup.size
quick_open_popup.popup_exclusive_on_parent(EditorInterface.get_script_editor(), get_center_editor_rect(pref_size))
quick_open_popup.set_category(category)
func open_override_popup():
var script: Script = get_current_script()
if (!script):
return
var pref_size: Vector2
if (override_popup == null):
override_popup = OVERRIDE_SCENE.instantiate()
override_popup.plugin = self
override_popup.outline_container = outline_container
override_popup.set_unparent_when_invisible(true)
pref_size = Vector2(500, 400) * get_editor_scale()
else:
pref_size = override_popup.size
override_popup.popup_exclusive_on_parent(EditorInterface.get_script_editor(), get_center_editor_rect(pref_size))
func hide_scripts_popup():
if (scripts_popup != null && scripts_popup.visible):
scripts_popup.hide.call_deferred()
func create_set_scripts_popup():
scripts_popup = PopupPanel.new()
scripts_popup.popup_hide.connect(restore_scripts_list)
# Need to be inside the tree, so it can be shown as popup for the tab container.
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
script_editor.add_child(scripts_popup)
multiline_tab_bar.set_popup(scripts_popup)
func restore_scripts_list():
script_filter_txt.text = &""
update_script_list_visibility()
scripts_item_list.get_parent().reparent(script_panel_split_container)
script_panel_split_container.move_child(scripts_item_list.get_parent(), 0)
func navigate_on_list(event: InputEvent, list: ItemList, submit: Callable):
if (event.is_action_pressed(&"ui_text_submit")):
list.accept_event()
var index: int = get_list_index(list)
if (index == -1):
return
submit.call(index)
list.accept_event()
elif (event.is_action_pressed(&"ui_down", true)):
var index: int = get_list_index(list)
if (index == list.item_count - 1):
return
navigate_list(list, index, 1)
elif (event.is_action_pressed(&"ui_up", true)):
var index: int = get_list_index(list)
if (index <= 0):
return
navigate_list(list, index, -1)
elif (event.is_action_pressed(&"ui_page_down", true)):
var index: int = get_list_index(list)
if (index == list.item_count - 1):
return
navigate_list(list, index, 5)
elif (event.is_action_pressed(&"ui_page_up", true)):
var index: int = get_list_index(list)
if (index <= 0):
return
navigate_list(list, index, -5)
elif (event is InputEventKey && list.item_count > 0 && !list.is_anything_selected()):
list.select(0)
func get_list_index(list: ItemList) -> int:
var items: PackedInt32Array = list.get_selected_items()
if (items.is_empty()):
return -1
return items[0]
func navigate_list(list: ItemList, index: int, amount: int):
index = clamp(index + amount, 0, list.item_count - 1)
list.select(index)
list.ensure_current_is_visible()
list.accept_event()
func get_center_editor_rect(pref_size: Vector2) -> Rect2i:
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
var position: Vector2 = script_editor.global_position + script_editor.size / 2 - pref_size / 2
return Rect2i(position, pref_size)
func open_outline_popup():
if (get_current_script() == null):
return
var button_flags: Array[bool] = outline_container.save_restore_filter()
var old_text: String = outline_filter_txt.text
outline_filter_txt.text = &""
var pref_size: Vector2
if (outline_popup == null):
outline_popup = PopupPanel.new()
outline_popup.set_unparent_when_invisible(true)
pref_size = Vector2(500, 400) * get_editor_scale()
else:
pref_size = outline_popup.size
var outline_initially_closed: bool = !files_panel.visible
if (outline_initially_closed):
files_panel.visible = true
files_panel.reparent(outline_popup)
outline_popup.popup_hide.connect(on_outline_popup_hidden.bind(outline_initially_closed, old_text, button_flags))
outline_popup.popup_exclusive_on_parent(EditorInterface.get_script_editor(), get_center_editor_rect(pref_size))
update_outline()
outline_filter_txt.grab_focus()
func on_outline_popup_hidden(outline_initially_closed: bool, old_text: String, button_flags: Array[bool]):
outline_popup.popup_hide.disconnect(on_outline_popup_hidden)
if outline_initially_closed:
files_panel.visible = false
files_panel.reparent(script_editor_split_container)
if (!is_outline_right):
script_editor_split_container.move_child(files_panel, 0)
outline_filter_txt.text = old_text
outline_container.restore_filter(button_flags)
update_outline()
func open_scripts_popup():
multiline_tab_bar.show_popup()
func get_current_script() -> Script:
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
return script_editor.get_current_script()
func select_script(selected_idx: int):
hide_scripts_popup()
scripts_item_list.item_selected.emit(selected_idx)
func goto_line(index: int):
if (outline_popup != null && outline_popup.visible):
outline_popup.hide.call_deferred()
EditorInterface.set_main_screen_editor("Script")
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
script_editor.goto_line(index)
var code_edit: CodeEdit = script_editor.get_current_editor().get_base_editor()
code_edit.set_caret_line(index)
code_edit.set_v_scroll(index)
code_edit.set_caret_column(code_edit.get_line(index).length())
code_edit.set_h_scroll(0)
code_edit.grab_focus()
func update_script_list_visibility():
scripts_item_list.get_parent().visible = is_script_list_visible
func sync_settings():
if (suppress_settings_sync):
return
var changed_settings: PackedStringArray = get_editor_settings().get_changed_settings()
for setting: String in changed_settings:
if (setting == ICON_SATURATION):
outline_container.reset_icons()
elif (setting == SHOW_MEMBERS):
show_members = get_setting(SHOW_MEMBERS, true)
if (!show_members):
set_setting(SHOW_MEMBERS, true)
elif (setting == MONOSPACE_OUTLINE):
update_outline_font()
if (!setting.begins_with(SCRIPT_IDE)):
continue
match (setting):
OUTLINE_POSITION_RIGHT:
var new_outline_right: bool = get_setting(OUTLINE_POSITION_RIGHT, is_outline_right)
if (new_outline_right != is_outline_right):
is_outline_right = new_outline_right
update_outline_position()
SCRIPT_LIST_VISIBLE:
var new_script_list_visible: bool = get_setting(SCRIPT_LIST_VISIBLE, is_script_list_visible)
if (new_script_list_visible != is_script_list_visible):
is_script_list_visible = new_script_list_visible
update_script_list_visibility()
SCRIPT_TABS_POSITION_TOP:
var new_script_tabs_top: bool = get_setting(SCRIPT_TABS_POSITION_TOP, is_script_tabs_top)
if (new_script_tabs_top != is_script_tabs_top):
is_script_tabs_top = new_script_tabs_top
update_tabs_position()
OUTLINE_ORDER:
var new_outline_order: PackedStringArray = get_outline_order()
outline_container.outline_order = new_outline_order
HIDE_PRIVATE_MEMBERS:
var new_value: bool = get_setting(HIDE_PRIVATE_MEMBERS, outline_container.is_hide_private_members)
outline_container.is_hide_private_members = new_value
SCRIPT_TABS_CLOSE_BUTTON_ALWAYS:
var new_value: bool = get_setting(SCRIPT_TABS_CLOSE_BUTTON_ALWAYS, multiline_tab_bar.show_close_button_always)
multiline_tab_bar.show_close_button_always = new_value
SCRIPT_TABS_SINGLELINE:
var new_value: bool = get_setting(SCRIPT_TABS_SINGLELINE, multiline_tab_bar.is_singleline_tabs)
multiline_tab_bar.is_singleline_tabs = new_value
SCRIPT_TABS_VISIBLE:
var new_value: bool = get_setting(SCRIPT_TABS_VISIBLE, multiline_tab_bar.visible)
multiline_tab_bar.visible = new_value
AUTO_NAVIGATE_IN_FS:
is_auto_navigate_in_fs = get_setting(AUTO_NAVIGATE_IN_FS, is_auto_navigate_in_fs)
OPEN_OUTLINE_POPUP:
open_outline_popup_shc = get_shortcut(OPEN_OUTLINE_POPUP)
OPEN_SCRIPTS_POPUP:
open_scripts_popup_shc = get_shortcut(OPEN_SCRIPTS_POPUP)
OPEN_QUICK_SEARCH_POPUP:
open_quick_search_popup_shc = get_shortcut(OPEN_QUICK_SEARCH_POPUP)
OPEN_QUICK_SEARCH_POPUP_SCENES:
open_quick_search_popup_scenes_shc = get_shortcut(OPEN_QUICK_SEARCH_POPUP_SCENES)
OPEN_QUICK_SEARCH_POPUP_GDSCRIPTS:
open_quick_search_popup_gdscripts_shc = get_shortcut(OPEN_QUICK_SEARCH_POPUP_GDSCRIPTS)
OPEN_QUICK_SEARCH_POPUP_RESOURCES:
open_quick_search_popup_resources_shc = get_shortcut(OPEN_QUICK_SEARCH_POPUP_RESOURCES)
OPEN_OVERRIDE_POPUP:
open_override_popup_shc = get_shortcut(OPEN_OVERRIDE_POPUP)
TAB_CYCLE_FORWARD:
tab_cycle_forward_shc = get_shortcut(TAB_CYCLE_FORWARD)
TAB_CYCLE_BACKWARD:
tab_cycle_backward_shc = get_shortcut(TAB_CYCLE_BACKWARD)
_:
outline_container.update_filter_buttons()
func update_selected_tab():
multiline_tab_bar.update_selected_tab()
func update_tabs_position():
var tab_container_parent: Control = multiline_tab_bar.get_parent()
if (is_script_tabs_top):
tab_container_parent.move_child(multiline_tab_bar, 0)
else:
tab_container_parent.move_child(multiline_tab_bar, tab_container_parent.get_child_count() - 1)
func update_outline():
outline_container.update_outline()
func update_outline_position():
if (is_outline_right):
# Try to restore the previous split offset.
var split_offset: float = script_editor_split_container.get_child(1).size.x
script_editor_split_container.split_offset = split_offset
script_editor_split_container.move_child(files_panel, 1)
else:
script_editor_split_container.move_child(files_panel, 0)
func update_outline_font():
var monospace_outline: bool = get_setting(MONOSPACE_OUTLINE, true)
if (monospace_outline):
var font: Font = EditorInterface.get_script_editor().get_theme_font(&"source", &"EditorFonts")
outline_container.outline.add_theme_font_override(&"font", font)
else:
outline_container.outline.remove_theme_font_override(&"font")
func update_keywords():
var script: Script = get_current_script()
if (script == null):
return
var new_script_type: StringName = script.get_instance_base_type()
if (old_script_type != new_script_type):
old_script_type = new_script_type
keywords.clear()
keywords["_static_init"] = true
register_virtual_methods(new_script_type)
func register_virtual_methods(clazz: String):
for method: Dictionary in ClassDB.class_get_method_list(clazz):
if (method[&"flags"] & METHOD_FLAG_VIRTUAL > 0):
keywords[method[&"name"]] = true
func get_editor_scale() -> float:
return EditorInterface.get_editor_scale()
func get_editor_settings() -> EditorSettings:
return EditorInterface.get_editor_settings()
func get_setting(property: StringName, alt: bool) -> bool:
var editor_settings: EditorSettings = get_editor_settings()
if (editor_settings.has_setting(property)):
return editor_settings.get_setting(property)
else:
editor_settings.set_setting(property, alt)
return alt
func set_setting(property: StringName, value: bool):
var editor_settings: EditorSettings = get_editor_settings()
suppress_settings_sync = true
editor_settings.set_setting(property, value)
suppress_settings_sync = false
func get_shortcut(property: StringName) -> Shortcut:
return get_editor_settings().get_setting(property)
func get_outline_order() -> PackedStringArray:
var new_outline_order: PackedStringArray
var editor_settings: EditorSettings = get_editor_settings()
if (editor_settings.has_setting(OUTLINE_ORDER)):
new_outline_order = editor_settings.get_setting(OUTLINE_ORDER)
else:
new_outline_order = OutlineContainer.DEFAULT_ORDER
editor_settings.set_setting(OUTLINE_ORDER, new_outline_order)
return new_outline_order
static func find_or_null(arr: Array[Node]) -> Control:
if (arr.is_empty()):
push_error("""Node that is needed for Script-IDE not found.
Plugin will not work correctly.
This might be due to some other plugins or changes in the Engine.
Please report this to Script-IDE, so we can figure out a fix.""")
return null
return arr[0] as Control
+1
View File
@@ -0,0 +1 @@
uid://bc0b5v66xdidn
@@ -0,0 +1,282 @@
## Quick open panel to quickly access all resources that are in the project.
## Initially shows all resources, but can be changed to more specific resources
## or filtered down with text.
@tool
extends PopupPanel
const ADDONS: StringName = &"res://addons"
const SEPARATOR: StringName = &" - "
const STRUCTURE_START: StringName = &"("
const STRUCTURE_END: StringName = &")"
const ORDER: Dictionary[StringName, int] = {
&"PackedScene": 0,
&"GDScript": 1,
&"Object": 2
}
const Plugin := preload("uid://bc0b5v66xdidn")
enum Category {
ALL = 0, SCENES = 1, GDSCRIPTS = 2, RESOURCES = 3
}
#region UI
@onready var filter_bar: TabBar = %FilterBar
@onready var search_option_btn: OptionButton = %SearchOptionBtn
@onready var filter_txt: LineEdit = %FilterTxt
@onready var files_list: ItemList = %FilesList
#endregion
var plugin: Plugin
var scenes: Array[FileData]
var scripts: Array[FileData]
var resources: Array[FileData]
var others: Array[FileData]
# For performance and memory considerations, we add all files into one reusable array.
var all_files: Array[FileData]
var is_rebuild_cache: bool = true
#region Plugin and Shortcut processing
func _ready() -> void:
files_list.item_selected.connect(open_file)
search_option_btn.item_selected.connect(rebuild_cache_and_ui.unbind(1))
filter_txt.text_changed.connect(fill_files_list.unbind(1))
filter_bar.tab_changed.connect(change_fill_files_list.unbind(1))
about_to_popup.connect(on_show)
var file_system: EditorFileSystem = EditorInterface.get_resource_filesystem()
file_system.filesystem_changed.connect(schedule_rebuild)
filter_txt.gui_input.connect(navigate_in_files_list)
func _shortcut_input(event: InputEvent) -> void:
if (!event.is_pressed() || event.is_echo()):
return
if (plugin.tab_cycle_forward_shc.matches_event(event)):
get_viewport().set_input_as_handled()
var new_tab: int = filter_bar.current_tab + 1
if (new_tab == filter_bar.get_tab_count()):
new_tab = 0
filter_bar.current_tab = new_tab
elif (plugin.tab_cycle_backward_shc.matches_event(event)):
get_viewport().set_input_as_handled()
var new_tab: int = filter_bar.current_tab - 1
if (new_tab == -1):
new_tab = filter_bar.get_tab_count() - 1
filter_bar.current_tab = new_tab
#endregion
func navigate_in_files_list(event: InputEvent):
plugin.navigate_on_list(event, files_list, open_file)
func set_category(category: Category):
var old_tab: int = filter_bar.current_tab
filter_bar.current_tab = category
# We need to manually trigger this when there is no tab change.
if (old_tab == category):
fill_files_list()
focus_and_select_first()
func open_file(index: int):
var file: String = files_list.get_item_metadata(index)
if (ResourceLoader.exists(file)):
var res: Resource = load(file)
if (res is Script):
EditorInterface.edit_script(res)
EditorInterface.set_main_screen_editor.call_deferred("Script")
else:
EditorInterface.edit_resource(res)
if (res is PackedScene):
EditorInterface.open_scene_from_path(file)
# Need to be deferred as it does not work otherwise.
var root: Node = EditorInterface.get_edited_scene_root()
if (root is Node3D):
EditorInterface.set_main_screen_editor.call_deferred("3D")
else:
EditorInterface.set_main_screen_editor.call_deferred("2D")
else:
# Text files (.txt, .md) will not be recognized, which seems to be a very bad
# limitation from the Engine. The methods called by the Engine are also not exposed.
# So we just select the file, which is better than nothing.
EditorInterface.select_file(file)
# Deferred as otherwise we get weird errors in the console.
# Probably due to this beeing called in a signal and auto unparent is true.
# 100% Engine bug or at least weird behavior.
hide.call_deferred()
func schedule_rebuild():
is_rebuild_cache = true
func on_show():
if (search_option_btn.selected != 0):
search_option_btn.selected = 0
is_rebuild_cache = true
if (is_rebuild_cache):
rebuild_cache()
filter_txt.select_all()
func rebuild_cache():
is_rebuild_cache = false
all_files.clear()
scenes.clear()
scripts.clear()
resources.clear()
others.clear()
build_file_cache()
func rebuild_cache_and_ui():
rebuild_cache()
fill_files_list()
focus_and_select_first()
func focus_and_select_first():
filter_txt.grab_focus()
if (files_list.item_count > 0):
files_list.select(0)
func build_file_cache():
var dir: EditorFileSystemDirectory = EditorInterface.get_resource_filesystem().get_filesystem()
build_file_cache_dir(dir)
scenes.sort_custom(sort_by_filter)
scripts.sort_custom(sort_by_filter)
resources.sort_custom(sort_by_filter)
others.sort_custom(sort_by_filter)
all_files.append_array(scenes)
all_files.append_array(scripts)
all_files.append_array(resources)
all_files.append_array(others)
func build_file_cache_dir(dir: EditorFileSystemDirectory):
for index: int in dir.get_subdir_count():
build_file_cache_dir(dir.get_subdir(index))
for index: int in dir.get_file_count():
var file: String = dir.get_file_path(index)
if (search_option_btn.get_selected_id() == 0 && file.begins_with(ADDONS)):
continue
var last_delimiter: int = file.rfind(&"/")
var file_name: String = file.substr(last_delimiter + 1)
var file_structure: String = &""
if (file_name.length() + 6 != file.length()):
file_structure = SEPARATOR + STRUCTURE_START + file.substr(6, last_delimiter - 6) + STRUCTURE_END
var file_data: FileData = FileData.new()
file_data.file = file
file_data.file_name = file_name
file_data.file_name_structure = file_name + file_structure
file_data.file_type = dir.get_file_type(index)
# Needed, as otherwise we have no icon.
if (file_data.file_type == &"Resource"):
file_data.file_type = &"Object"
match (file.get_extension()):
&"tscn": scenes.append(file_data)
&"gd": scripts.append(file_data)
&"tres": resources.append(file_data)
&"gdshader": resources.append(file_data)
_: others.append(file_data)
func change_fill_files_list():
fill_files_list()
focus_and_select_first()
func fill_files_list():
files_list.clear()
if (filter_bar.current_tab == 0):
fill_files_list_with(all_files, sort_by_order_filter)
elif (filter_bar.current_tab == 1):
fill_files_list_with(scenes, sort_by_filter)
elif (filter_bar.current_tab == 2):
fill_files_list_with(scripts, sort_by_filter)
elif (filter_bar.current_tab == 3):
fill_files_list_with(resources, sort_by_filter)
elif (filter_bar.current_tab == 4):
fill_files_list_with(others, sort_by_filter)
func fill_files_list_with(files: Array[FileData], comparator: Callable):
var filter_text: String = filter_txt.text
if (!filter_text.is_empty()):
files.sort_custom(comparator)
for file_data: FileData in files:
var file: String = file_data.file
if (filter_text.is_empty() || filter_text.is_subsequence_ofn(file)):
var icon: Texture2D = EditorInterface.get_base_control().get_theme_icon(file_data.file_type, &"EditorIcons")
files_list.add_item(file_data.file_name_structure, icon)
files_list.set_item_metadata(files_list.item_count - 1, file)
files_list.set_item_tooltip(files_list.item_count - 1, file)
func sort_by_order_filter(file_data1: FileData, file_data2: FileData) -> bool:
var order1: int = ORDER.get(file_data1.file_type, ORDER.size())
var order2: int = ORDER.get(file_data2.file_type, ORDER.size())
if (order1 != order2):
return order1 < order2
return sort_by_filter(file_data1, file_data2)
func sort_by_filter(file_data1: FileData, file_data2: FileData) -> bool:
var filter_text: String = filter_txt.text
var name1: String = file_data1.file_name
var name2: String = file_data2.file_name
for index: int in filter_text.length():
var a_oob: bool = index >= name1.length()
var b_oob: bool = index >= name2.length()
if (a_oob && b_oob):
return false
elif (a_oob):
return true
elif (b_oob):
return false
var char: String = filter_text[index]
var a_match: bool = char == name1[index]
var b_match: bool = char == name2[index]
if (a_match && !b_match):
return true
elif (b_match && !a_match):
return false
return name1 < name2
class FileData:
var file: String
var file_name: String
var file_name_structure: String
var file_type: StringName
@@ -0,0 +1 @@
uid://cgwp4rl1udqbb
@@ -0,0 +1,149 @@
[gd_scene format=3 uid="uid://d2pttchmj3n7q"]
[ext_resource type="Script" uid="uid://cgwp4rl1udqbb" path="res://addons/script-ide/quickopen/quick_open_popup.gd" id="1_6d8qa"]
[sub_resource type="Image" id="Image_70lqw"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 16, 225, 225, 225, 134, 224, 224, 224, 209, 224, 224, 224, 245, 224, 224, 224, 245, 224, 224, 224, 208, 224, 224, 224, 131, 236, 236, 236, 13, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 73, 224, 224, 224, 228, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 225, 225, 225, 225, 68, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 73, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 183, 224, 224, 224, 198, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 198, 224, 224, 224, 189, 224, 224, 224, 255, 224, 224, 224, 254, 224, 224, 224, 65, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 16, 224, 224, 224, 228, 224, 224, 224, 255, 224, 224, 224, 120, 226, 226, 226, 60, 224, 224, 224, 255, 225, 225, 225, 109, 225, 225, 225, 110, 224, 224, 224, 255, 226, 226, 226, 60, 224, 224, 224, 128, 224, 224, 224, 255, 225, 225, 225, 223, 234, 234, 234, 12, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 134, 224, 224, 224, 255, 225, 225, 225, 183, 255, 255, 255, 0, 224, 224, 224, 153, 224, 224, 224, 243, 255, 255, 255, 4, 255, 255, 255, 4, 224, 224, 224, 244, 225, 225, 225, 151, 255, 255, 255, 1, 225, 225, 225, 191, 224, 224, 224, 255, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 209, 224, 224, 224, 255, 224, 224, 224, 72, 255, 255, 255, 0, 224, 224, 224, 216, 224, 224, 224, 198, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 199, 224, 224, 224, 214, 255, 255, 255, 0, 226, 226, 226, 78, 224, 224, 224, 255, 224, 224, 224, 206, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 243, 224, 224, 224, 255, 226, 226, 226, 78, 255, 255, 255, 0, 224, 224, 224, 244, 225, 225, 225, 151, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 152, 224, 224, 224, 242, 255, 255, 255, 1, 227, 227, 227, 81, 224, 224, 224, 255, 224, 224, 224, 241, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 245, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 229, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 147, 225, 225, 225, 149, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 230, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 244, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 208, 224, 224, 224, 255, 224, 224, 224, 147, 224, 224, 224, 161, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 235, 224, 224, 224, 235, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 160, 225, 225, 225, 150, 224, 224, 224, 255, 224, 224, 224, 205, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 131, 224, 224, 224, 255, 224, 224, 224, 189, 255, 255, 255, 1, 224, 224, 224, 152, 224, 224, 224, 243, 255, 255, 255, 4, 255, 255, 255, 4, 224, 224, 224, 244, 225, 225, 225, 151, 255, 255, 255, 2, 225, 225, 225, 199, 224, 224, 224, 255, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 0, 236, 236, 236, 13, 224, 224, 224, 225, 224, 224, 224, 255, 224, 224, 224, 128, 225, 225, 225, 67, 224, 224, 224, 255, 225, 225, 225, 110, 226, 226, 226, 111, 224, 224, 224, 255, 225, 225, 225, 67, 225, 225, 225, 135, 224, 224, 224, 255, 224, 224, 224, 221, 234, 234, 234, 12, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 68, 224, 224, 224, 254, 224, 224, 224, 255, 224, 224, 224, 194, 224, 224, 224, 220, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 219, 224, 224, 224, 196, 224, 224, 224, 255, 224, 224, 224, 253, 227, 227, 227, 62, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 66, 224, 224, 224, 225, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 220, 226, 226, 226, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 237, 237, 237, 14, 224, 224, 224, 130, 224, 224, 224, 206, 224, 224, 224, 244, 224, 224, 224, 244, 224, 224, 224, 205, 225, 225, 225, 124, 230, 230, 230, 10, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}
[sub_resource type="ImageTexture" id="ImageTexture_p6ab8"]
image = SubResource("Image_70lqw")
[sub_resource type="Image" id="Image_xbsxl"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 25, 226, 226, 226, 70, 229, 229, 229, 39, 255, 255, 255, 0, 226, 226, 226, 103, 224, 224, 224, 219, 224, 224, 224, 156, 255, 255, 255, 0, 255, 255, 255, 0, 226, 226, 226, 26, 225, 225, 225, 25, 255, 255, 255, 0, 224, 224, 224, 74, 224, 224, 224, 177, 226, 226, 226, 111, 255, 255, 255, 0, 224, 224, 224, 98, 224, 224, 224, 255, 225, 225, 225, 182, 255, 255, 255, 0, 228, 228, 228, 46, 224, 224, 224, 255, 224, 224, 224, 197, 255, 255, 255, 0, 224, 224, 224, 57, 224, 224, 224, 255, 224, 224, 224, 187, 255, 255, 255, 0, 225, 225, 225, 42, 224, 224, 224, 255, 224, 224, 224, 232, 255, 255, 255, 6, 224, 224, 224, 8, 225, 225, 225, 182, 224, 224, 224, 153, 255, 255, 255, 7, 255, 255, 255, 0, 228, 228, 228, 37, 255, 255, 255, 7, 255, 255, 255, 0, 229, 229, 229, 19, 224, 224, 224, 237, 224, 224, 224, 198, 225, 225, 225, 17, 255, 255, 255, 0, 227, 227, 227, 71, 224, 224, 224, 48, 255, 255, 255, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 228, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 73, 224, 224, 224, 226, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}
[sub_resource type="ImageTexture" id="ImageTexture_bbwjp"]
image = SubResource("Image_xbsxl")
[sub_resource type="Image" id="Image_hmtyg"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 33, 224, 224, 224, 255, 224, 224, 224, 255, 231, 231, 231, 31, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 226, 226, 226, 95, 224, 224, 224, 57, 255, 255, 255, 0, 224, 224, 224, 99, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 93, 255, 255, 255, 0, 224, 224, 224, 57, 224, 224, 224, 90, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 93, 224, 224, 224, 255, 224, 224, 224, 254, 224, 224, 224, 165, 224, 224, 224, 217, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 214, 225, 225, 225, 167, 224, 224, 224, 254, 224, 224, 224, 254, 224, 224, 224, 88, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 228, 228, 228, 55, 224, 224, 224, 254, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 253, 225, 225, 225, 51, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 166, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 160, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 33, 224, 224, 224, 99, 224, 224, 224, 217, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 186, 224, 224, 224, 32, 224, 224, 224, 33, 224, 224, 224, 187, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 215, 224, 224, 224, 98, 224, 224, 224, 32, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 229, 229, 229, 38, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 231, 231, 231, 31, 226, 226, 226, 95, 224, 224, 224, 216, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 187, 225, 225, 225, 34, 226, 226, 226, 35, 224, 224, 224, 192, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 213, 226, 226, 226, 95, 231, 231, 231, 31, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 166, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 163, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 57, 224, 224, 224, 254, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 254, 227, 227, 227, 54, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 90, 224, 224, 224, 254, 224, 224, 224, 253, 224, 224, 224, 161, 225, 225, 225, 215, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 213, 224, 224, 224, 162, 224, 224, 224, 253, 224, 224, 224, 253, 226, 226, 226, 86, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 88, 225, 225, 225, 51, 255, 255, 255, 0, 224, 224, 224, 98, 224, 224, 224, 255, 224, 224, 224, 255, 226, 226, 226, 95, 255, 255, 255, 0, 227, 227, 227, 53, 226, 226, 226, 86, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 32, 224, 224, 224, 255, 224, 224, 224, 255, 231, 231, 231, 31, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}
[sub_resource type="ImageTexture" id="ImageTexture_ghict"]
image = SubResource("Image_hmtyg")
[sub_resource type="Image" id="Image_whndc"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 4, 224, 224, 224, 99, 224, 224, 224, 213, 224, 224, 224, 212, 224, 224, 224, 97, 255, 255, 255, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 4, 224, 224, 224, 99, 224, 224, 224, 222, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 220, 224, 224, 224, 97, 255, 255, 255, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 4, 224, 224, 224, 99, 224, 224, 224, 222, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 213, 226, 226, 226, 87, 224, 224, 224, 88, 224, 224, 224, 214, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 220, 224, 224, 224, 97, 255, 255, 255, 4, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 199, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 215, 224, 224, 224, 89, 255, 255, 255, 2, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 2, 224, 224, 224, 90, 224, 224, 224, 216, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 194, 255, 255, 255, 0, 255, 255, 255, 4, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 221, 224, 224, 224, 99, 255, 255, 255, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 5, 225, 225, 225, 101, 225, 225, 225, 223, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 3, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 213, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 222, 225, 225, 225, 100, 225, 225, 225, 100, 225, 225, 225, 223, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 3, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 2, 226, 226, 226, 87, 224, 224, 224, 213, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 2, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 2, 226, 226, 226, 87, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 1, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 100, 255, 255, 255, 5, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 196, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 223, 225, 225, 225, 101, 255, 255, 255, 5, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 193, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 3, 225, 225, 225, 93, 224, 224, 224, 218, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 223, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 216, 225, 225, 225, 91, 255, 255, 255, 2, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 3, 225, 225, 225, 93, 224, 224, 224, 218, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 216, 225, 225, 225, 91, 255, 255, 255, 2, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 3, 225, 225, 225, 93, 224, 224, 224, 208, 225, 225, 225, 207, 225, 225, 225, 91, 255, 255, 255, 2, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}
[sub_resource type="ImageTexture" id="ImageTexture_grjtr"]
image = SubResource("Image_whndc")
[sub_resource type="Image" id="Image_y5or7"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 184, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 181, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 226, 226, 226, 77, 225, 225, 225, 76, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 8, 224, 224, 224, 222, 224, 224, 224, 221, 224, 224, 224, 8, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 120, 224, 224, 224, 32, 224, 224, 224, 128, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 226, 226, 226, 35, 224, 224, 224, 248, 224, 224, 224, 195, 224, 224, 224, 247, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 247, 225, 225, 225, 34, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 180, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 178, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 181, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 180, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}
[sub_resource type="ImageTexture" id="ImageTexture_xupch"]
image = SubResource("Image_y5or7")
[sub_resource type="Image" id="Image_00i5q"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 68, 224, 224, 224, 184, 224, 224, 224, 240, 224, 224, 224, 232, 224, 224, 224, 186, 227, 227, 227, 62, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 129, 224, 224, 224, 254, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 122, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 68, 224, 224, 224, 254, 224, 224, 224, 254, 224, 224, 224, 123, 224, 224, 224, 32, 224, 224, 224, 33, 225, 225, 225, 125, 224, 224, 224, 254, 224, 224, 224, 254, 226, 226, 226, 69, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 184, 224, 224, 224, 255, 224, 224, 224, 123, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 125, 224, 224, 224, 255, 225, 225, 225, 174, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 240, 224, 224, 224, 255, 231, 231, 231, 31, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 226, 226, 226, 35, 224, 224, 224, 255, 224, 224, 224, 233, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 232, 224, 224, 224, 255, 224, 224, 224, 32, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 228, 228, 228, 37, 224, 224, 224, 255, 224, 224, 224, 228, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 186, 224, 224, 224, 255, 224, 224, 224, 123, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 130, 224, 224, 224, 255, 224, 224, 224, 173, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 62, 224, 224, 224, 255, 224, 224, 224, 254, 225, 225, 225, 126, 225, 225, 225, 34, 227, 227, 227, 36, 224, 224, 224, 131, 224, 224, 224, 255, 224, 224, 224, 255, 226, 226, 226, 77, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 122, 224, 224, 224, 254, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 210, 231, 231, 231, 21, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 226, 226, 226, 69, 225, 225, 225, 174, 224, 224, 224, 233, 224, 224, 224, 228, 224, 224, 224, 173, 226, 226, 226, 77, 224, 224, 224, 210, 224, 224, 224, 255, 224, 224, 224, 210, 231, 231, 231, 21, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 231, 231, 231, 21, 224, 224, 224, 210, 224, 224, 224, 255, 224, 224, 224, 210, 231, 231, 231, 21, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 231, 231, 231, 21, 224, 224, 224, 210, 224, 224, 224, 255, 224, 224, 224, 210, 231, 231, 231, 21, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 231, 231, 231, 21, 224, 224, 224, 210, 224, 224, 224, 227, 225, 225, 225, 34, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 231, 231, 231, 21, 225, 225, 225, 34, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}
[sub_resource type="ImageTexture" id="ImageTexture_w6vkw"]
image = SubResource("Image_00i5q")
[node name="QuickOpenPanel" type="PopupPanel" unique_id=1197081327]
oversampling_override = 1.0
size = Vector2i(627, 100)
visible = true
script = ExtResource("1_6d8qa")
[node name="PanelContainer" type="PanelContainer" parent="." unique_id=170455275]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 4.0
offset_top = 4.0
offset_right = -4.0
offset_bottom = -4.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer" unique_id=811819428]
layout_mode = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer" unique_id=679259085]
layout_mode = 2
theme_override_constants/separation = 5
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer" unique_id=150235257]
layout_mode = 2
theme_override_constants/separation = 4
[node name="FilterBar" type="TabBar" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer" unique_id=660360907]
unique_name_in_owner = true
layout_mode = 2
current_tab = 0
clip_tabs = false
scrolling_enabled = false
tab_count = 5
tab_0/title = "All"
tab_0/icon = SubResource("ImageTexture_p6ab8")
tab_1/title = "Scene"
tab_1/icon = SubResource("ImageTexture_bbwjp")
tab_2/title = "GDScript"
tab_2/icon = SubResource("ImageTexture_ghict")
tab_3/title = "Resource"
tab_3/icon = SubResource("ImageTexture_grjtr")
tab_4/title = "Other"
tab_4/icon = SubResource("ImageTexture_xupch")
[node name="SearchOptionBtn" type="OptionButton" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer" unique_id=902993731]
unique_name_in_owner = true
layout_mode = 2
selected = 0
item_count = 2
popup/item_0/text = "Project"
popup/item_0/id = 0
popup/item_1/text = "Project+Addons"
popup/item_1/id = 1
[node name="FilterTxt" type="LineEdit" parent="PanelContainer/MarginContainer/VBoxContainer" unique_id=721767691]
unique_name_in_owner = true
layout_mode = 2
placeholder_text = "Filter files"
right_icon = SubResource("ImageTexture_w6vkw")
[node name="FilesList" type="ItemList" parent="PanelContainer/MarginContainer/VBoxContainer" unique_id=190949578]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
allow_reselect = true
@@ -0,0 +1,47 @@
## The CodeEdit that is used when the editor is split, to show the split script.
@tool
extends CodeEdit
var last_v_scroll: float
func _ready() -> void:
editable = false
caret_draw_when_editable_disabled = true
set_v_scroll.call_deferred(last_v_scroll)
static func new_from(from_code_edit: CodeEdit) -> CodeEdit:
var new_code_edit: CodeEdit = new()
new_code_edit.text = from_code_edit.text
new_code_edit.syntax_highlighter = from_code_edit.syntax_highlighter
new_code_edit.highlight_all_occurrences = from_code_edit.highlight_all_occurrences
new_code_edit.highlight_current_line = from_code_edit.highlight_current_line
new_code_edit.use_default_word_separators = from_code_edit.use_default_word_separators
new_code_edit.use_custom_word_separators = from_code_edit.use_custom_word_separators
new_code_edit.custom_word_separators = from_code_edit.custom_word_separators
new_code_edit.line_folding = from_code_edit.line_folding
new_code_edit.line_length_guidelines = from_code_edit.line_length_guidelines
new_code_edit.gutters_draw_line_numbers = from_code_edit.gutters_draw_line_numbers
new_code_edit.gutters_draw_fold_gutter = from_code_edit.gutters_draw_fold_gutter
new_code_edit.minimap_draw = from_code_edit.minimap_draw
new_code_edit.minimap_width = from_code_edit.minimap_width
new_code_edit.delimiter_strings = from_code_edit.delimiter_strings
new_code_edit.delimiter_comments = from_code_edit.delimiter_comments
new_code_edit.indent_automatic = from_code_edit.indent_automatic
new_code_edit.indent_size = from_code_edit.indent_size
new_code_edit.indent_use_spaces = from_code_edit.indent_use_spaces
new_code_edit.indent_automatic_prefixes = from_code_edit.indent_automatic_prefixes
new_code_edit.draw_control_chars = from_code_edit.draw_control_chars
new_code_edit.draw_tabs = from_code_edit.draw_tabs
new_code_edit.draw_spaces = from_code_edit.draw_spaces
new_code_edit.last_v_scroll = from_code_edit.scroll_vertical
return new_code_edit
@@ -0,0 +1 @@
uid://boy48rhhyrph
+84
View File
@@ -0,0 +1,84 @@
## Button that is used as a custom tab implementation for the multiline tab bar.
@tool
extends Button
signal close_pressed
signal right_clicked
signal dragged_over
signal dropped(source_index: int, target_index: int)
var close_button: Button
func _init() -> void:
alignment = HORIZONTAL_ALIGNMENT_LEFT
action_mode = ACTION_MODE_BUTTON_PRESS
auto_translate_mode = Node.AUTO_TRANSLATE_MODE_DISABLED
toggle_mode = true
func show_close_button():
if (close_button == null):
close_button = create_close_button()
add_child(close_button)
close_button.set_anchors_and_offsets_preset(Control.PRESET_CENTER_RIGHT)
func hide_close_button():
if (close_button != null):
remove_child(close_button)
func create_close_button() -> Button:
close_button = Button.new()
close_button.icon = EditorInterface.get_editor_theme().get_icon(&"Close", &"EditorIcons")
close_button.flat = true
close_button.focus_mode = Control.FOCUS_NONE
close_button.pressed.connect(on_close_pressed)
return close_button
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton && event.pressed:
if event.button_index == MOUSE_BUTTON_MIDDLE:
on_close_pressed()
elif (event.button_index == MOUSE_BUTTON_RIGHT):
button_pressed = true
on_right_click()
func on_right_click():
right_clicked.emit()
func on_close_pressed() -> void:
close_pressed.emit()
func _get_drag_data(at_position: Vector2) -> Variant:
var preview: Button = Button.new()
preview.text = text
preview.icon = icon
preview.alignment = HORIZONTAL_ALIGNMENT_LEFT
preview.auto_translate_mode = Node.AUTO_TRANSLATE_MODE_DISABLED
preview.add_theme_stylebox_override(&"normal", get_theme_stylebox(&"normal"))
set_drag_preview(preview)
var drag_data: Dictionary[String, Variant]
drag_data["type"] = "script_list_element"
drag_data["script_list_element"] = EditorInterface.get_script_editor().get_current_editor()
drag_data["index"] = get_index()
return drag_data
func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
if !(data is Dictionary):
return false
var can_drop: bool = data.has("index")
if (can_drop):
dragged_over.emit()
return can_drop
func _drop_data(at_position: Vector2, data: Variant) -> void:
if (!_can_drop_data(at_position, data)):
return
dropped.emit(data["index"], get_index())
@@ -0,0 +1 @@
uid://bppomxp4mri2o
@@ -0,0 +1,503 @@
## Tab bar that can show tabs in multiple lines (wrap), when there is not enough horizontal space.
@tool
extends PanelContainer
const CLOSE_BTN_SPACER: String = " "
const CustomTab := preload("uid://bppomxp4mri2o")
const Plugin := preload("uid://bc0b5v66xdidn")
signal split_toggled
@onready var multiline_tab_bar: HFlowContainer = %MultilineTabBar
@onready var split_btn: Button = %SplitBtn
@onready var popup_btn: Button = %PopupBtn
#region Theme
var tab_hovered: StyleBoxFlat
var tab_focus: StyleBoxFlat
var tab_selected: StyleBoxFlat
var tab_unselected: StyleBoxFlat
var font_selected_color: Color
var font_unselected_color: Color
var font_hovered_color: Color
#endregion
var plugin: Plugin
var show_close_button_always: bool = false : set = set_show_close_button_always
var is_singleline_tabs: bool = false : set = set_singleline_tabs
var tab_group: ButtonGroup = ButtonGroup.new()
# Existing Engine components, set from the plugin
var script_filter_txt: LineEdit
var scripts_item_list: ItemList
var scripts_tab_container: TabContainer
var popup: PopupPanel
var suppress_theme_changed: bool
var split: bool
var split_path: String
var split_icon: Texture2D
var last_drag_over_tab: CustomTab
var drag_marker: ColorRect
var current_tab: CustomTab
#region Plugin and related tab handling processing
func _init() -> void:
tab_group.pressed.connect(on_new_tab_selected)
func _ready() -> void:
popup_btn.pressed.connect(show_popup)
split_btn.gui_input.connect(on_right_click)
split_btn.toggled.connect(toggle_split.unbind(1))
split_icon = split_btn.icon
set_process(false)
if (plugin == null):
return
schedule_update()
func _notification(what: int) -> void:
if (what == NOTIFICATION_DRAG_END || what == NOTIFICATION_MOUSE_EXIT):
clear_drag_mark()
return
if (what == NOTIFICATION_THEME_CHANGED):
if (suppress_theme_changed):
return
suppress_theme_changed = true
add_theme_stylebox_override(&"panel", EditorInterface.get_editor_theme().get_stylebox(&"tabbar_background", &"TabContainer"))
suppress_theme_changed = false
tab_hovered = EditorInterface.get_editor_theme().get_stylebox(&"tab_hovered", &"TabContainer")
tab_focus = EditorInterface.get_editor_theme().get_stylebox(&"tab_focus", &"TabContainer")
tab_selected = EditorInterface.get_editor_theme().get_stylebox(&"tab_selected", &"TabContainer")
tab_unselected = EditorInterface.get_editor_theme().get_stylebox(&"tab_unselected", &"TabContainer")
if (drag_marker == null):
drag_marker = ColorRect.new()
drag_marker.set_anchors_and_offsets_preset(PRESET_LEFT_WIDE)
drag_marker.mouse_filter = Control.MOUSE_FILTER_IGNORE
drag_marker.custom_minimum_size.x = 4 * EditorInterface.get_editor_scale()
drag_marker.color = EditorInterface.get_editor_theme().get_color(&"drop_mark_color", &"TabContainer")
font_hovered_color = EditorInterface.get_editor_theme().get_color(&"font_hovered_color", &"TabContainer")
font_selected_color = EditorInterface.get_editor_theme().get_color(&"font_selected_color", &"TabContainer")
font_unselected_color = EditorInterface.get_editor_theme().get_color(&"font_unselected_color", &"TabContainer")
# If this is called too early.
if (multiline_tab_bar == null):
return
for tab: CustomTab in get_tabs():
update_tab_style(tab)
func _process(delta: float) -> void:
sync_tabs_with_item_list()
if (is_singleline_tabs):
shift_singleline_tabs()
set_process(false)
func _shortcut_input(event: InputEvent) -> void:
if (!event.is_pressed() || event.is_echo()):
return
if (!is_visible_in_tree()):
return
if (current_tab == null):
return
if (plugin.tab_cycle_forward_shc.matches_event(event)):
get_viewport().set_input_as_handled()
var tab_count: int = get_tab_count()
if (tab_count <= 1):
return
var index: int = current_tab.get_index()
var new_tab: int = index + 1
if (new_tab == tab_count):
new_tab = 0
var tab: CustomTab = get_tab(new_tab)
tab.button_pressed = true
elif (plugin.tab_cycle_backward_shc.matches_event(event)):
get_viewport().set_input_as_handled()
var tab_count: int = get_tab_count()
if (tab_count <= 1):
return
var index: int = current_tab.get_index()
var new_tab: int = index - 1
if (new_tab == -1):
new_tab = tab_count - 1
var tab: CustomTab = get_tab(new_tab)
tab.button_pressed = true
func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
if !(data is Dictionary):
return false
var can_drop: bool = data.has("index") && data["index"] != get_tab_count() - 1
if (can_drop):
on_drag_over(get_tab(get_tab_count() - 1))
return can_drop
func _drop_data(at_position: Vector2, data: Variant) -> void:
if (!_can_drop_data(at_position, data)):
return
on_drag_drop(data["index"], get_tab_count() - 1)
#endregion
func schedule_update():
set_process(true)
func set_split(value: bool) -> void:
split = value
if (split):
var index: int = current_tab.get_index()
split_path = scripts_item_list.get_item_tooltip(index)
split_btn.text = scripts_item_list.get_item_text(index)
split_btn.icon = scripts_item_list.get_item_icon(index)
split_btn.tooltip_text = split_path
else:
split_btn.icon = split_icon
split_btn.text = ""
func is_split() -> bool:
return split
func toggle_split():
split_toggled.emit()
func set_split_disabled(value: bool):
split_btn.disabled = value
func on_right_click(event: InputEvent):
if (!split_btn.button_pressed):
return
if !(event is InputEventMouseButton):
return
var mouse_event: InputEventMouseButton = event
if (!mouse_event.is_pressed() || mouse_event.button_index != MOUSE_BUTTON_RIGHT):
return
split_btn.button_pressed = false
if (split_path != null && ResourceLoader.exists(split_path)):
var res: Resource = load(split_path)
EditorInterface.edit_resource(res)
func on_drag_drop(source_index: int, target_index: int):
var child: Node = scripts_tab_container.get_child(source_index)
scripts_tab_container.move_child(child, target_index);
var tab: CustomTab = get_tab(target_index)
tab.grab_focus()
func on_drag_over(tab: CustomTab):
if (last_drag_over_tab == tab):
return
# The drag marker should always be orphan when here.
tab.add_child(drag_marker)
last_drag_over_tab = tab
func clear_drag_mark():
if (last_drag_over_tab == null):
return
last_drag_over_tab = null
if (drag_marker.get_parent() != null):
drag_marker.get_parent().remove_child(drag_marker)
func update_tabs():
on_scripts_changed()
for tab: CustomTab in get_tabs():
update_tab(tab)
func get_tabs() -> Array[Node]:
return multiline_tab_bar.get_children()
func update_selected_tab():
update_tab(tab_group.get_pressed_button())
func update_tab(tab: CustomTab):
if (tab == null):
return
var index: int = tab.get_index()
tab.text = scripts_item_list.get_item_text(index)
tab.icon = scripts_item_list.get_item_icon(index)
tab.tooltip_text = scripts_item_list.get_item_tooltip(index)
update_icon_color(tab, scripts_item_list.get_item_icon_modulate(index))
if (scripts_item_list.is_selected(index)):
tab.button_pressed = true
tab.text += CLOSE_BTN_SPACER
elif (show_close_button_always):
tab.text += CLOSE_BTN_SPACER
func get_tab(index: int) -> CustomTab:
if (index < 0 || index >= get_tab_count()):
return null
return multiline_tab_bar.get_child(index)
func get_tab_count() -> int:
return multiline_tab_bar.get_child_count()
func add_tab() -> CustomTab:
var tab: CustomTab = CustomTab.new()
tab.button_group = tab_group
if (show_close_button_always):
tab.show_close_button()
update_tab_style(tab)
tab.close_pressed.connect(on_tab_close_pressed.bind(tab))
tab.right_clicked.connect(on_tab_right_click.bind(tab))
tab.mouse_exited.connect(clear_drag_mark)
tab.dragged_over.connect(on_drag_over.bind(tab))
tab.dropped.connect(on_drag_drop)
multiline_tab_bar.add_child(tab)
return tab
func update_tab_style(tab: CustomTab):
tab.add_theme_stylebox_override(&"normal", tab_unselected)
tab.add_theme_stylebox_override(&"hover", tab_hovered)
tab.add_theme_stylebox_override(&"hover_pressed", tab_hovered)
tab.add_theme_stylebox_override(&"focus", tab_focus)
tab.add_theme_stylebox_override(&"pressed", tab_selected)
tab.add_theme_color_override(&"font_color", font_unselected_color)
tab.add_theme_color_override(&"font_hover_color", font_hovered_color)
tab.add_theme_color_override(&"font_pressed_color", font_selected_color)
func update_icon_color(tab: CustomTab, color: Color):
tab.add_theme_color_override(&"icon_normal_color", color)
tab.add_theme_color_override(&"icon_hover_color", color)
tab.add_theme_color_override(&"icon_hover_pressed_color", color)
tab.add_theme_color_override(&"icon_pressed_color", color)
tab.add_theme_color_override(&"icon_focus_color", color)
func on_tab_right_click(tab: CustomTab):
var index: int = tab.get_index()
scripts_item_list.item_clicked.emit(index, scripts_item_list.get_local_mouse_position(), MOUSE_BUTTON_RIGHT)
func on_new_tab_selected(tab: CustomTab):
# Hide and show close button.
if (!show_close_button_always):
if (current_tab != null):
current_tab.hide_close_button()
if (tab != null):
tab.show_close_button()
update_script_text_filter()
var index: int = tab.get_index()
if (scripts_item_list != null && !scripts_item_list.is_selected(index)):
scripts_item_list.select(index)
scripts_item_list.item_selected.emit(index)
scripts_item_list.ensure_current_is_visible()
# Remove spacing from previous tab.
if (!show_close_button_always && current_tab != null):
update_tab(current_tab)
current_tab = tab
## Removes the script filter text and emits the signal so that the tabs stay
## and we do not break anything there.
func update_script_text_filter():
if (script_filter_txt.text != &""):
script_filter_txt.text = &""
script_filter_txt.text_changed.emit(&"")
func on_tab_close_pressed(tab: CustomTab) -> void:
scripts_item_list.item_clicked.emit(tab.get_index(), scripts_item_list.get_local_mouse_position(), MOUSE_BUTTON_MIDDLE)
func sync_tabs_with_item_list() -> void:
if (get_tab_count() > scripts_item_list.item_count):
for index: int in range(get_tab_count() - 1, scripts_item_list.item_count - 1, -1):
var tab: CustomTab = get_tab(index)
if (tab == current_tab):
current_tab = null
multiline_tab_bar.remove_child(tab)
free_tab(tab)
for index: int in scripts_item_list.item_count:
var tab: CustomTab = get_tab(index)
if (tab == null):
tab = add_tab()
update_tab(tab)
func tab_changed():
on_scripts_changed()
update_script_text_filter()
# When the tab change was not triggered by our component,
# we need to sync the selection.
update_tab(get_tab(scripts_tab_container.current_tab))
func on_scripts_changed():
update_script_text_filter()
popup_btn.text = "(" + str(scripts_item_list.item_count) + ")"
func script_order_changed() -> void:
schedule_update()
func set_popup(new_popup: PopupPanel) -> void:
popup = new_popup
func show_popup() -> void:
if (popup == null):
return
scripts_item_list.get_parent().reparent(popup)
scripts_item_list.get_parent().visible = true
popup.size = Vector2(250 * get_editor_scale(), get_parent().size.y - size.y)
popup.position = popup_btn.get_screen_position() - Vector2(popup.size.x, 0)
popup.popup()
script_filter_txt.grab_focus()
func get_editor_scale() -> float:
return EditorInterface.get_editor_scale()
func set_show_close_button_always(new_value: bool):
if (show_close_button_always == new_value):
return
show_close_button_always = new_value
if (multiline_tab_bar == null):
return
for tab: CustomTab in get_tabs():
tab.text = scripts_item_list.get_item_text(tab.get_index())
if (show_close_button_always):
tab.text += CLOSE_BTN_SPACER
if (!tab.button_pressed):
tab.show_close_button()
else:
if (!tab.button_pressed):
tab.hide_close_button()
else:
tab.text += CLOSE_BTN_SPACER
func free_tabs():
if (drag_marker != null):
drag_marker.free()
for tab: CustomTab in get_tabs():
free_tab(tab)
func free_tab(tab: CustomTab):
if (tab.close_button != null):
tab.close_button.free()
tab.free()
#region Singeline handling
func set_singleline_tabs(new_value: bool):
if (is_singleline_tabs == new_value):
return
is_singleline_tabs = new_value
if (is_singleline_tabs):
multiline_tab_bar.item_rect_changed.connect(shift_singleline_tabs)
tab_group.pressed.connect(shift_singleline_tabs.unbind(1))
shift_singleline_tabs()
else:
multiline_tab_bar.item_rect_changed.disconnect(shift_singleline_tabs)
tab_group.pressed.disconnect(shift_singleline_tabs)
for tab: CustomTab in get_tabs():
tab.visible = true
func shift_singleline_tabs():
if (current_tab == null):
return
var tabs: Array[Node] = get_tabs()
var tab_count: int = tabs.size()
if (tab_count == 0):
return
var tab_bar_width: float = multiline_tab_bar.size.x
var current_index: int = current_tab.get_index()
var first: int = current_index
var last: int = current_index
var used_width: float = current_tab.size.x
# Pass 1: Expand through already-visible tabs first
while (first > 0):
var prev_tab: Node = tabs[first - 1]
if (!prev_tab.visible || used_width + prev_tab.size.x > tab_bar_width):
break
first -= 1
used_width += prev_tab.size.x
while (last < tab_count - 1):
var next_tab: Node = tabs[last + 1]
if (!next_tab.visible || used_width + next_tab.size.x > tab_bar_width):
break
last += 1
used_width += next_tab.size.x
# Pass 2: Fill remaining space with any tabs
while (first > 0):
var prev_tab: Node = tabs[first - 1]
if (used_width + prev_tab.size.x > tab_bar_width):
break
first -= 1
used_width += prev_tab.size.x
while (last < tab_count - 1):
var next_tab: Node = tabs[last + 1]
if (used_width + next_tab.size.x > tab_bar_width):
break
last += 1
used_width += next_tab.size.x
for index: int in tab_count:
var tab: Node = tabs.get(index)
tab.visible = index >= first && index <= last
#endregion
@@ -0,0 +1 @@
uid://l1rdargfn67o
@@ -0,0 +1,43 @@
[gd_scene format=3 uid="uid://vjuhunm2uboy"]
[ext_resource type="Script" uid="uid://l1rdargfn67o" path="res://addons/script-ide/tabbar/multiline_tab_bar.gd" id="1_8jr3v"]
[sub_resource type="DPITexture" id="DPITexture_split"]
_source = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\"><path fill=\"#e0e0e0\" d=\"M7.5 0v16h1V0z\"/></svg>"
[sub_resource type="DPITexture" id="DPITexture_scripts"]
_source = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\"><path fill=\"#e0e0e0\" d=\"M8 0a2 2 0 0 0 0 4 2 2 0 0 0 0-4zm0 6a2 2 0 0 0 0 4 2 2 0 0 0 0-4zm0 6a2 2 0 0 0 0 4 2 2 0 0 0 0-4z\"/></svg>"
[node name="MultilineTabContainer" type="PanelContainer" unique_id=635880120]
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 24.0
grow_horizontal = 2
size_flags_horizontal = 3
script = ExtResource("1_8jr3v")
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=932291510]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 0
[node name="MultilineTabBar" type="HFlowContainer" parent="HBoxContainer" unique_id=2135340034]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/h_separation = 0
theme_override_constants/v_separation = 0
[node name="SplitBtn" type="Button" parent="HBoxContainer" unique_id=813915450]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
toggle_mode = true
icon = SubResource("DPITexture_split")
alignment = 0
[node name="PopupBtn" type="Button" parent="HBoxContainer" unique_id=1586924518]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
icon = SubResource("DPITexture_scripts")