making sure the issue comes from GDUnit addon folder
All checks were successful
Create tag and build when new code gets to main / Export (push) Successful in 7m6s
All checks were successful
Create tag and build when new code gets to main / Export (push) Successful in 7m6s
This commit is contained in:
0
addons/gdUnit4/src/ui/GdUnitConsole.gd
Normal file
0
addons/gdUnit4/src/ui/GdUnitConsole.gd
Normal file
0
addons/gdUnit4/src/ui/GdUnitConsole.gd.uid
Normal file
0
addons/gdUnit4/src/ui/GdUnitConsole.gd.uid
Normal file
0
addons/gdUnit4/src/ui/GdUnitConsole.tscn
Normal file
0
addons/gdUnit4/src/ui/GdUnitConsole.tscn
Normal file
36
addons/gdUnit4/src/ui/GdUnitFonts.gd
Normal file
36
addons/gdUnit4/src/ui/GdUnitFonts.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
@tool
|
||||
class_name GdUnitFonts
|
||||
extends RefCounted
|
||||
|
||||
|
||||
static func init_fonts(item: CanvasItem) -> float:
|
||||
# set default size
|
||||
item.set("theme_override_font_sizes/font_size", 16)
|
||||
|
||||
if Engine.is_editor_hint():
|
||||
var base_control := EditorInterface.get_base_control()
|
||||
# source modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs
|
||||
# https://github.com/godotengine/godot/blob/9ee1873ae1e09c217ac24a5800007f63cb895615/editor/editor_log.cpp#L65
|
||||
var output_source_mono := base_control.get_theme_font("output_source_mono", "EditorFonts")
|
||||
var output_source_bold_italic := base_control.get_theme_font("output_source_bold_italic", "EditorFonts")
|
||||
var output_source_italic := base_control.get_theme_font("output_source_italic", "EditorFonts")
|
||||
var output_source_bold := base_control.get_theme_font("output_source_bold", "EditorFonts")
|
||||
var output_source := base_control.get_theme_font("output_source", "EditorFonts")
|
||||
var settings := EditorInterface.get_editor_settings()
|
||||
var scale_factor := EditorInterface.get_editor_scale()
|
||||
var font_size: float = settings.get_setting("interface/editor/main_font_size")
|
||||
|
||||
font_size *= scale_factor
|
||||
item.set("theme_override_fonts/normal_font", output_source)
|
||||
item.set("theme_override_fonts/bold_font", output_source_bold)
|
||||
item.set("theme_override_fonts/italics_font", output_source_italic)
|
||||
item.set("theme_override_fonts/bold_italics_font", output_source_bold_italic)
|
||||
item.set("theme_override_fonts/mono_font", output_source_mono)
|
||||
item.set("theme_override_font_sizes/font_size", font_size)
|
||||
item.set("theme_override_font_sizes/normal_font_size", font_size)
|
||||
item.set("theme_override_font_sizes/bold_font_size", font_size)
|
||||
item.set("theme_override_font_sizes/italics_font_size", font_size)
|
||||
item.set("theme_override_font_sizes/bold_italics_font_size", font_size)
|
||||
item.set("theme_override_font_sizes/mono_font_size", font_size)
|
||||
return font_size
|
||||
return 16.0
|
||||
0
addons/gdUnit4/src/ui/GdUnitFonts.gd.uid
Normal file
0
addons/gdUnit4/src/ui/GdUnitFonts.gd.uid
Normal file
0
addons/gdUnit4/src/ui/GdUnitInspector.gd
Normal file
0
addons/gdUnit4/src/ui/GdUnitInspector.gd
Normal file
0
addons/gdUnit4/src/ui/GdUnitInspector.gd.uid
Normal file
0
addons/gdUnit4/src/ui/GdUnitInspector.gd.uid
Normal file
0
addons/gdUnit4/src/ui/GdUnitInspector.tscn
Normal file
0
addons/gdUnit4/src/ui/GdUnitInspector.tscn
Normal file
0
addons/gdUnit4/src/ui/GdUnitUiTools.gd
Normal file
0
addons/gdUnit4/src/ui/GdUnitUiTools.gd
Normal file
0
addons/gdUnit4/src/ui/GdUnitUiTools.gd.uid
Normal file
0
addons/gdUnit4/src/ui/GdUnitUiTools.gd.uid
Normal file
0
addons/gdUnit4/src/ui/ScriptEditorControls.gd
Normal file
0
addons/gdUnit4/src/ui/ScriptEditorControls.gd
Normal file
0
addons/gdUnit4/src/ui/ScriptEditorControls.gd.uid
Normal file
0
addons/gdUnit4/src/ui/ScriptEditorControls.gd.uid
Normal file
0
addons/gdUnit4/src/ui/menu/GdUnitContextMenuItem.gd
Normal file
0
addons/gdUnit4/src/ui/menu/GdUnitContextMenuItem.gd
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorMonitor.gd
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorMonitor.gd
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorMonitor.gd.uid
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorMonitor.gd.uid
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorMonitor.tscn
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorMonitor.tscn
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorProgressBar.gd
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorProgressBar.gd
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorStatusBar.gd
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorStatusBar.gd
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorStatusBar.tscn
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorStatusBar.tscn
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorToolBar.gd
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorToolBar.gd
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorToolBar.gd.uid
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorToolBar.gd.uid
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorToolBar.tscn
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorToolBar.tscn
Normal file
1245
addons/gdUnit4/src/ui/parts/InspectorTreeMainPanel.gd
Normal file
1245
addons/gdUnit4/src/ui/parts/InspectorTreeMainPanel.gd
Normal file
File diff suppressed because it is too large
Load Diff
0
addons/gdUnit4/src/ui/parts/InspectorTreePanel.tscn
Normal file
0
addons/gdUnit4/src/ui/parts/InspectorTreePanel.tscn
Normal file
327
addons/gdUnit4/src/ui/settings/GdUnitSettingsDialog.gd
Normal file
327
addons/gdUnit4/src/ui/settings/GdUnitSettingsDialog.gd
Normal file
@@ -0,0 +1,327 @@
|
||||
@tool
|
||||
extends Window
|
||||
|
||||
const EAXAMPLE_URL := "https://github.com/MikeSchulze/gdUnit4-examples/archive/refs/heads/master.zip"
|
||||
const GdUnitTools := preload ("res://addons/gdUnit4/src/core/GdUnitTools.gd")
|
||||
const GdUnitUpdateClient = preload ("res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd")
|
||||
|
||||
@onready var _update_client: GdUnitUpdateClient = $GdUnitUpdateClient
|
||||
@onready var _version_label: RichTextLabel = %version
|
||||
@onready var _btn_install: Button = %btn_install_examples
|
||||
@onready var _progress_bar: ProgressBar = %ProgressBar
|
||||
@onready var _progress_text: Label = %progress_lbl
|
||||
@onready var _properties_template: Control = $property_template
|
||||
@onready var _properties_common: Control = % "common-content"
|
||||
@onready var _properties_ui: Control = % "ui-content"
|
||||
@onready var _properties_shortcuts: Control = % "shortcut-content"
|
||||
@onready var _properties_report: Control = % "report-content"
|
||||
@onready var _input_capture: GdUnitInputCapture = %GdUnitInputCapture
|
||||
@onready var _property_error: Window = % "propertyError"
|
||||
@onready var _tab_container: TabContainer = %Properties
|
||||
@onready var _update_tab: Control = %Update
|
||||
|
||||
var _font_size: float
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_name("GdUnitSettingsDialog")
|
||||
# initialize for testing
|
||||
if not Engine.is_editor_hint():
|
||||
GdUnitSettings.setup()
|
||||
GdUnit4Version.init_version_label(_version_label)
|
||||
_font_size = GdUnitFonts.init_fonts(_version_label)
|
||||
setup_properties(_properties_common, GdUnitSettings.COMMON_SETTINGS)
|
||||
setup_properties(_properties_ui, GdUnitSettings.UI_SETTINGS)
|
||||
setup_properties(_properties_report, GdUnitSettings.REPORT_SETTINGS)
|
||||
setup_properties(_properties_shortcuts, GdUnitSettings.SHORTCUT_SETTINGS)
|
||||
check_for_update()
|
||||
|
||||
|
||||
func _sort_by_key(left: GdUnitProperty, right: GdUnitProperty) -> bool:
|
||||
return left.name() < right.name()
|
||||
|
||||
|
||||
func setup_properties(properties_parent: Control, property_category: String) -> void:
|
||||
# Do remove first potential previous added properties (could be happened when the dlg is opened at twice)
|
||||
for child in properties_parent.get_children():
|
||||
properties_parent.remove_child(child)
|
||||
|
||||
var category_properties := GdUnitSettings.list_settings(property_category)
|
||||
# sort by key
|
||||
category_properties.sort_custom(_sort_by_key)
|
||||
var theme_ := Theme.new()
|
||||
theme_.set_constant("h_separation", "GridContainer", 12)
|
||||
var last_category := "!"
|
||||
var min_size_overall := 0.0
|
||||
var labels := []
|
||||
var inputs := []
|
||||
var info_labels := []
|
||||
var grid: GridContainer = null
|
||||
for p in category_properties:
|
||||
var min_size_ := 0.0
|
||||
var property: GdUnitProperty = p
|
||||
var current_category := property.category()
|
||||
if not grid or current_category != last_category:
|
||||
grid = GridContainer.new()
|
||||
grid.columns = 4
|
||||
grid.theme = theme_
|
||||
|
||||
var sub_category: Control = _properties_template.get_child(3).duplicate()
|
||||
var category_label: Label = sub_category.get_child(0)
|
||||
category_label.text = current_category.capitalize()
|
||||
sub_category.custom_minimum_size.y = _font_size + 16
|
||||
properties_parent.add_child(sub_category)
|
||||
properties_parent.add_child(grid)
|
||||
last_category = current_category
|
||||
# property name
|
||||
var label: Label = _properties_template.get_child(0).duplicate()
|
||||
label.text = _to_human_readable(property.name())
|
||||
labels.append(label)
|
||||
grid.add_child(label)
|
||||
|
||||
# property reset btn
|
||||
var reset_btn: Button = _properties_template.get_child(1).duplicate()
|
||||
reset_btn.icon = _get_btn_icon("Reload")
|
||||
reset_btn.disabled = property.value() == property.default()
|
||||
grid.add_child(reset_btn)
|
||||
|
||||
# property type specific input element
|
||||
var input: Node = _create_input_element(property, reset_btn)
|
||||
inputs.append(input)
|
||||
grid.add_child(input)
|
||||
@warning_ignore("return_value_discarded")
|
||||
reset_btn.pressed.connect(_on_btn_property_reset_pressed.bind(property, input, reset_btn))
|
||||
# property help text
|
||||
var info: Label = _properties_template.get_child(2).duplicate()
|
||||
info.text = property.help()
|
||||
info_labels.append(info)
|
||||
grid.add_child(info)
|
||||
if min_size_overall < min_size_:
|
||||
min_size_overall = min_size_
|
||||
|
||||
for controls: Array in [labels, inputs, info_labels]:
|
||||
var _size: float = controls.map(func(c: Control) -> float: return c.size.x).max()
|
||||
min_size_overall += _size
|
||||
for control: Control in controls:
|
||||
control.custom_minimum_size.x = _size
|
||||
properties_parent.custom_minimum_size.x = min_size_overall
|
||||
|
||||
|
||||
func _create_input_element(property: GdUnitProperty, reset_btn: Button) -> Node:
|
||||
if property.is_selectable_value():
|
||||
var options := OptionButton.new()
|
||||
options.alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
for value in property.value_set():
|
||||
options.add_item(value)
|
||||
options.item_selected.connect(_on_option_selected.bind(property, reset_btn))
|
||||
options.select(property.int_value())
|
||||
return options
|
||||
if property.type() == TYPE_BOOL:
|
||||
var check_btn := CheckButton.new()
|
||||
check_btn.toggled.connect(_on_property_text_changed.bind(property, reset_btn))
|
||||
check_btn.button_pressed = property.value()
|
||||
return check_btn
|
||||
if property.type() in [TYPE_INT, TYPE_STRING]:
|
||||
var input := LineEdit.new()
|
||||
input.text_changed.connect(_on_property_text_changed.bind(property, reset_btn))
|
||||
input.set_context_menu_enabled(false)
|
||||
input.set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER)
|
||||
input.set_expand_to_text_length_enabled(true)
|
||||
input.text = str(property.value())
|
||||
return input
|
||||
if property.type() == TYPE_PACKED_INT32_ARRAY:
|
||||
var key_input_button := Button.new()
|
||||
var value:PackedInt32Array = property.value()
|
||||
key_input_button.text = to_shortcut(value)
|
||||
key_input_button.pressed.connect(_on_shortcut_change.bind(key_input_button, property, reset_btn))
|
||||
return key_input_button
|
||||
return Control.new()
|
||||
|
||||
|
||||
func to_shortcut(keys: PackedInt32Array) -> String:
|
||||
var input_event := InputEventKey.new()
|
||||
for key in keys:
|
||||
match key:
|
||||
KEY_CTRL: input_event.ctrl_pressed = true
|
||||
KEY_SHIFT: input_event.shift_pressed = true
|
||||
KEY_ALT: input_event.alt_pressed = true
|
||||
KEY_META: input_event.meta_pressed = true
|
||||
_:
|
||||
input_event.keycode = key as Key
|
||||
return input_event.as_text()
|
||||
|
||||
|
||||
func to_keys(input_event: InputEventKey) -> PackedInt32Array:
|
||||
var keys := PackedInt32Array()
|
||||
if input_event.ctrl_pressed:
|
||||
keys.append(KEY_CTRL)
|
||||
if input_event.shift_pressed:
|
||||
keys.append(KEY_SHIFT)
|
||||
if input_event.alt_pressed:
|
||||
keys.append(KEY_ALT)
|
||||
if input_event.meta_pressed:
|
||||
keys.append(KEY_META)
|
||||
keys.append(input_event.keycode)
|
||||
return keys
|
||||
|
||||
|
||||
func _to_human_readable(value: String) -> String:
|
||||
return value.split("/")[-1].capitalize()
|
||||
|
||||
|
||||
func _get_btn_icon(p_name: String) -> Texture2D:
|
||||
if not Engine.is_editor_hint():
|
||||
var placeholder := PlaceholderTexture2D.new()
|
||||
placeholder.size = Vector2(8, 8)
|
||||
return placeholder
|
||||
return GdUnitUiTools.get_icon(p_name)
|
||||
|
||||
|
||||
func _install_examples() -> void:
|
||||
_init_progress(5)
|
||||
update_progress("Downloading examples")
|
||||
await get_tree().process_frame
|
||||
var tmp_path := GdUnitFileAccess.create_temp_dir("download")
|
||||
var zip_file := tmp_path + "/examples.zip"
|
||||
var response: GdUnitUpdateClient.HttpResponse = await _update_client.request_zip_package(EAXAMPLE_URL, zip_file)
|
||||
if response.status() != 200:
|
||||
push_warning("Examples cannot be retrieved from GitHub! \n Error code: %d : %s" % [response.status(), response.response()])
|
||||
update_progress("Install examples failed! Try it later again.")
|
||||
await get_tree().create_timer(3).timeout
|
||||
stop_progress()
|
||||
return
|
||||
# extract zip to tmp
|
||||
update_progress("Install examples into project")
|
||||
var result := GdUnitFileAccess.extract_zip(zip_file, "res://gdUnit4-examples/")
|
||||
if result.is_error():
|
||||
update_progress("Install examples failed! %s" % result.error_message())
|
||||
await get_tree().create_timer(3).timeout
|
||||
stop_progress()
|
||||
return
|
||||
update_progress("Refresh project")
|
||||
await rescan()
|
||||
await reimport("res://gdUnit4-examples/")
|
||||
|
||||
update_progress("Examples successfully installed")
|
||||
await get_tree().create_timer(3).timeout
|
||||
stop_progress()
|
||||
|
||||
|
||||
func rescan() -> void:
|
||||
await get_tree().process_frame
|
||||
var fs := EditorInterface.get_resource_filesystem()
|
||||
fs.scan_sources()
|
||||
while fs.is_scanning():
|
||||
await get_tree().create_timer(1).timeout
|
||||
|
||||
|
||||
func reimport(path: String) -> void:
|
||||
await get_tree().process_frame
|
||||
var files := DirAccess.get_files_at(path)
|
||||
EditorInterface.get_resource_filesystem().reimport_files(files)
|
||||
for directory in DirAccess.get_directories_at(path):
|
||||
reimport(directory)
|
||||
|
||||
|
||||
func check_for_update() -> void:
|
||||
if not GdUnitSettings.is_update_notification_enabled():
|
||||
return
|
||||
var response :GdUnitUpdateClient.HttpResponse = await _update_client.request_latest_version()
|
||||
if response.status() != 200:
|
||||
printerr("Latest version information cannot be retrieved from GitHub!")
|
||||
printerr("Error: %s" % response.response())
|
||||
return
|
||||
var latest_version := _update_client.extract_latest_version(response)
|
||||
if latest_version.is_greater(GdUnit4Version.current()):
|
||||
var tab_index := _tab_container.get_tab_idx_from_control(_update_tab)
|
||||
_tab_container.set_tab_button_icon(tab_index, GdUnitUiTools.get_icon("Notification", Color.YELLOW))
|
||||
_tab_container.set_tab_tooltip(tab_index, "An new update is available.")
|
||||
|
||||
|
||||
func _on_btn_report_bug_pressed() -> void:
|
||||
@warning_ignore("return_value_discarded")
|
||||
OS.shell_open("https://github.com/MikeSchulze/gdUnit4/issues/new?assignees=MikeSchulze&labels=bug&projects=projects%2F5&template=bug_report.yml&title=GD-XXX%3A+Describe+the+issue+briefly")
|
||||
|
||||
|
||||
func _on_btn_request_feature_pressed() -> void:
|
||||
@warning_ignore("return_value_discarded")
|
||||
OS.shell_open("https://github.com/MikeSchulze/gdUnit4/issues/new?assignees=MikeSchulze&labels=enhancement&projects=&template=feature_request.md&title=")
|
||||
|
||||
|
||||
func _on_btn_install_examples_pressed() -> void:
|
||||
_btn_install.disabled = true
|
||||
await _install_examples()
|
||||
_btn_install.disabled = false
|
||||
|
||||
|
||||
func _on_btn_close_pressed() -> void:
|
||||
hide()
|
||||
|
||||
|
||||
func _on_btn_property_reset_pressed(property: GdUnitProperty, input: Node, reset_btn: Button) -> void:
|
||||
if input is CheckButton:
|
||||
var is_default_pressed: bool = property.default()
|
||||
(input as CheckButton).button_pressed = is_default_pressed
|
||||
elif input is LineEdit:
|
||||
(input as LineEdit).text = str(property.default())
|
||||
# we have to update manually for text input fields because of no change event is emited
|
||||
_on_property_text_changed(property.default(), property, reset_btn)
|
||||
elif input is OptionButton:
|
||||
(input as OptionButton).select(0)
|
||||
_on_option_selected(0, property, reset_btn)
|
||||
elif input is Button:
|
||||
var value: PackedInt32Array = property.default()
|
||||
(input as Button).text = to_shortcut(value)
|
||||
_on_property_text_changed(value, property, reset_btn)
|
||||
|
||||
|
||||
func _on_property_text_changed(new_value: Variant, property: GdUnitProperty, reset_btn: Button) -> void:
|
||||
property.set_value(new_value)
|
||||
reset_btn.disabled = property.value() == property.default()
|
||||
var error: Variant = GdUnitSettings.update_property(property)
|
||||
if error:
|
||||
var label: Label = _property_error.get_child(0) as Label
|
||||
label.set_text(str(error))
|
||||
var control := gui_get_focus_owner()
|
||||
_property_error.show()
|
||||
if control != null:
|
||||
_property_error.position = control.global_position + Vector2(self.position) + Vector2(40, 40)
|
||||
|
||||
|
||||
func _on_option_selected(index: int, property: GdUnitProperty, reset_btn: Button) -> void:
|
||||
property.set_value(index)
|
||||
reset_btn.disabled = property.value() == property.default()
|
||||
GdUnitSettings.update_property(property)
|
||||
|
||||
|
||||
func _on_shortcut_change(input_button: Button, property: GdUnitProperty, reset_btn: Button) -> void:
|
||||
_input_capture.set_custom_minimum_size(_properties_shortcuts.get_size())
|
||||
_input_capture.visible = true
|
||||
_input_capture.show()
|
||||
_properties_shortcuts.visible = false
|
||||
set_process_input(false)
|
||||
_input_capture.reset()
|
||||
var input_event: InputEventKey = await _input_capture.input_completed
|
||||
input_button.text = input_event.as_text()
|
||||
_on_property_text_changed(to_keys(input_event), property, reset_btn)
|
||||
_properties_shortcuts.visible = true
|
||||
set_process_input(true)
|
||||
|
||||
|
||||
func _init_progress(max_value: int) -> void:
|
||||
_progress_bar.visible = true
|
||||
_progress_bar.max_value = max_value
|
||||
_progress_bar.value = 0
|
||||
|
||||
|
||||
func _progress() -> void:
|
||||
_progress_bar.value += 1
|
||||
|
||||
|
||||
func stop_progress() -> void:
|
||||
_progress_bar.visible = false
|
||||
|
||||
|
||||
func update_progress(message: String) -> void:
|
||||
_progress_text.text = message
|
||||
_progress_bar.value += 1
|
||||
0
addons/gdUnit4/src/ui/settings/logo.png
Normal file
0
addons/gdUnit4/src/ui/settings/logo.png
Normal file
0
addons/gdUnit4/src/ui/settings/logo.png.import
Normal file
0
addons/gdUnit4/src/ui/settings/logo.png.import
Normal file
129
addons/gdUnit4/src/ui/templates/TestSuiteTemplate.gd
Normal file
129
addons/gdUnit4/src/ui/templates/TestSuiteTemplate.gd
Normal file
@@ -0,0 +1,129 @@
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
@onready var _template_editor :CodeEdit = $VBoxContainer/EdiorLayout/Editor
|
||||
@onready var _tags_editor :CodeEdit = $Tags/MarginContainer/TextEdit
|
||||
@onready var _title_bar :Panel = $VBoxContainer/sub_category
|
||||
@onready var _save_button :Button = $VBoxContainer/Panel/HBoxContainer/Save
|
||||
@onready var _selected_type :OptionButton = $VBoxContainer/EdiorLayout/Editor/MarginContainer/HBoxContainer/SelectType
|
||||
@onready var _show_tags :PopupPanel = $Tags
|
||||
|
||||
|
||||
var gd_key_words :PackedStringArray = ["extends", "class_name", "const", "var", "onready", "func", "void", "pass"]
|
||||
var gdunit_key_words :PackedStringArray = ["GdUnitTestSuite", "before", "after", "before_test", "after_test"]
|
||||
var _selected_template :int
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
setup_editor_colors()
|
||||
setup_fonts()
|
||||
setup_supported_types()
|
||||
load_template(GdUnitTestSuiteTemplate.TEMPLATE_ID_GD)
|
||||
setup_tags_help()
|
||||
|
||||
|
||||
func _notification(what :int) -> void:
|
||||
if what == EditorSettings.NOTIFICATION_EDITOR_SETTINGS_CHANGED:
|
||||
setup_fonts()
|
||||
|
||||
|
||||
func setup_editor_colors() -> void:
|
||||
if not Engine.is_editor_hint():
|
||||
return
|
||||
|
||||
var background_color := get_editor_color("text_editor/theme/highlighting/background_color", Color(0.1155, 0.132, 0.1595, 1))
|
||||
var text_color := get_editor_color("text_editor/theme/highlighting/text_color", Color(0.8025, 0.81, 0.8225, 1))
|
||||
var selection_color := get_editor_color("text_editor/theme/highlighting/selection_color", Color(0.44, 0.73, 0.98, 0.4))
|
||||
|
||||
for e :CodeEdit in [_template_editor, _tags_editor]:
|
||||
var editor :CodeEdit = e
|
||||
editor.add_theme_color_override("background_color", background_color)
|
||||
editor.add_theme_color_override("font_color", text_color)
|
||||
editor.add_theme_color_override("font_readonly_color", text_color)
|
||||
editor.add_theme_color_override("font_selected_color", selection_color)
|
||||
setup_highlighter(editor)
|
||||
|
||||
|
||||
func setup_highlighter(editor :CodeEdit) -> void:
|
||||
var highlighter := CodeHighlighter.new()
|
||||
editor.set_syntax_highlighter(highlighter)
|
||||
var number_color := get_editor_color("text_editor/theme/highlighting/number_color", Color(0.63, 1, 0.88, 1))
|
||||
var symbol_color := get_editor_color("text_editor/theme/highlighting/symbol_color", Color(0.67, 0.79, 1, 1))
|
||||
var function_color := get_editor_color("text_editor/theme/highlighting/function_color", Color(0.34, 0.7, 1, 1))
|
||||
var member_variable_color := get_editor_color("text_editor/theme/highlighting/member_variable_color", Color(0.736, 0.88, 1, 1))
|
||||
var comment_color := get_editor_color("text_editor/theme/highlighting/comment_color", Color(0.8025, 0.81, 0.8225, 0.5))
|
||||
var keyword_color := get_editor_color("text_editor/theme/highlighting/keyword_color", Color(1, 0.44, 0.52, 1))
|
||||
var base_type_color := get_editor_color("text_editor/theme/highlighting/base_type_color", Color(0.26, 1, 0.76, 1))
|
||||
var annotation_color := get_editor_color("text_editor/theme/highlighting/gdscript/annotation_color", Color(1, 0.7, 0.45, 1))
|
||||
|
||||
highlighter.clear_color_regions()
|
||||
highlighter.clear_keyword_colors()
|
||||
highlighter.add_color_region("#", "", comment_color, true)
|
||||
highlighter.add_color_region("${", "}", Color.YELLOW)
|
||||
highlighter.add_color_region("'", "'", Color.YELLOW)
|
||||
highlighter.add_color_region("\"", "\"", Color.YELLOW)
|
||||
highlighter.number_color = number_color
|
||||
highlighter.symbol_color = symbol_color
|
||||
highlighter.function_color = function_color
|
||||
highlighter.member_variable_color = member_variable_color
|
||||
highlighter.add_keyword_color("@", annotation_color)
|
||||
highlighter.add_keyword_color("warning_ignore", annotation_color)
|
||||
for word in gd_key_words:
|
||||
highlighter.add_keyword_color(word, keyword_color)
|
||||
for word in gdunit_key_words:
|
||||
highlighter.add_keyword_color(word, base_type_color)
|
||||
|
||||
|
||||
## Using this function to avoid null references to colors on inital Godot installations.
|
||||
## For more details show https://github.com/MikeSchulze/gdUnit4/issues/533
|
||||
func get_editor_color(property_name: String, default: Color) -> Color:
|
||||
var settings := EditorInterface.get_editor_settings()
|
||||
return settings.get_setting(property_name) if settings.has_setting(property_name) else default
|
||||
|
||||
|
||||
func setup_fonts() -> void:
|
||||
if _template_editor:
|
||||
@warning_ignore("return_value_discarded")
|
||||
GdUnitFonts.init_fonts(_template_editor)
|
||||
var font_size := GdUnitFonts.init_fonts(_tags_editor)
|
||||
_title_bar.size.y = font_size + 16
|
||||
_title_bar.custom_minimum_size.y = font_size + 16
|
||||
|
||||
|
||||
func setup_supported_types() -> void:
|
||||
_selected_type.clear()
|
||||
_selected_type.add_item("GD - GDScript", GdUnitTestSuiteTemplate.TEMPLATE_ID_GD)
|
||||
_selected_type.add_item("C# - CSharpScript", GdUnitTestSuiteTemplate.TEMPLATE_ID_CS)
|
||||
|
||||
|
||||
func setup_tags_help() -> void:
|
||||
_tags_editor.set_text(GdUnitTestSuiteTemplate.load_tags(_selected_template))
|
||||
|
||||
|
||||
func load_template(template_id :int) -> void:
|
||||
_selected_template = template_id
|
||||
_template_editor.set_text(GdUnitTestSuiteTemplate.load_template(template_id))
|
||||
|
||||
|
||||
func _on_Restore_pressed() -> void:
|
||||
_template_editor.set_text(GdUnitTestSuiteTemplate.default_template(_selected_template))
|
||||
GdUnitTestSuiteTemplate.reset_to_default(_selected_template)
|
||||
_save_button.disabled = true
|
||||
|
||||
|
||||
func _on_Save_pressed() -> void:
|
||||
GdUnitTestSuiteTemplate.save_template(_selected_template, _template_editor.get_text())
|
||||
_save_button.disabled = true
|
||||
|
||||
|
||||
func _on_Tags_pressed() -> void:
|
||||
_show_tags.popup_centered_ratio(.5)
|
||||
|
||||
|
||||
func _on_Editor_text_changed() -> void:
|
||||
_save_button.disabled = false
|
||||
|
||||
|
||||
func _on_SelectType_item_selected(index :int) -> void:
|
||||
load_template(_selected_type.get_item_id(index))
|
||||
setup_tags_help()
|
||||
Reference in New Issue
Block a user