From a408c937386fb69dd7c6ee32453df2830b1574cf Mon Sep 17 00:00:00 2001 From: Nullpointer Date: Wed, 11 Dec 2024 13:40:24 +0100 Subject: [PATCH] append --- .gitignore | 1 + addons/.gdunit_update/GdUnitUpdate.gd | 236 ------------------ addons/.gdunit_update/GdUnitUpdate.tscn | 86 ------- .../src/ui/settings/GdUnitSettingsDialog.tscn | 4 +- addons/gdUnit4/src/update/GdMarkDownReader.gd | 91 +++++-- addons/gdUnit4/src/update/GdUnitUpdate.gd | 2 +- addons/gdUnit4/src/update/GdUnitUpdate.tscn | 2 +- .../gdUnit4/src/update/GdUnitUpdateClient.gd | 1 - .../gdUnit4/src/update/GdUnitUpdateNotify.gd | 32 ++- .../src/update/GdUnitUpdateNotify.tscn | 4 +- .../src/update/assets/progress-background.png | Bin 1047 -> 0 bytes .../assets/progress-background.png.import | 34 --- addons/gdUnit4/test/update/bbcodeView.gd | 20 +- addons/gdUnit4/test/update/bbcodeView.tscn | 4 +- .../resources/http_response_releases.txt | 164 ++++++++++++ project.godot | 2 +- 16 files changed, 274 insertions(+), 409 deletions(-) delete mode 100644 addons/.gdunit_update/GdUnitUpdate.gd delete mode 100644 addons/.gdunit_update/GdUnitUpdate.tscn delete mode 100644 addons/gdUnit4/src/update/assets/progress-background.png delete mode 100644 addons/gdUnit4/src/update/assets/progress-background.png.import create mode 100644 addons/gdUnit4/test/update/resources/http_response_releases.txt diff --git a/.gitignore b/.gitignore index defae281..4e88ab2b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ icon.png.import *.gd.uid *.cs.uid *.json.uid +*.txt.uid # Mono-specific ignores .mono/ diff --git a/addons/.gdunit_update/GdUnitUpdate.gd b/addons/.gdunit_update/GdUnitUpdate.gd deleted file mode 100644 index add5dea8..00000000 --- a/addons/.gdunit_update/GdUnitUpdate.gd +++ /dev/null @@ -1,236 +0,0 @@ -@tool -extends Container - -const GdUnitTools := preload("res://addons/gdUnit4/src/core/GdUnitTools.gd") -const GdUnitUpdateClient := preload("res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd") - -@onready var _progress_content :RichTextLabel = %message -@onready var _progress_bar :TextureProgressBar = %progress - - -var _debug_mode := false -var _update_client :GdUnitUpdateClient -var _download_url :String - - -func _ready() -> void: - message_h4("Press 'Update' to start!", Color.GREEN) - init_progress(5) - - -func _process(_delta :float) -> void: - if _progress_content != null and _progress_content.is_visible_in_tree(): - _progress_content.queue_redraw() - - -func init_progress(max_value : int) -> void: - _progress_bar.max_value = max_value - _progress_bar.value = 1 - - -func setup(update_client :GdUnitUpdateClient, download_url :String) -> void: - _update_client = update_client - _download_url = download_url - - -func update_progress(message :String) -> void: - message_h4(message, Color.GREEN) - _progress_bar.value += 1 - if _debug_mode: - await get_tree().create_timer(3).timeout - await get_tree().create_timer(.2).timeout - - -func _colored(message :String, color :Color) -> String: - return "[color=#%s]%s[/color]" % [color.to_html(), message] - - -func message_h4(message :String, color :Color) -> void: - _progress_content.clear() - _progress_content.append_text("[font_size=16]%s[/font_size]" % _colored(message, color)) - - -@warning_ignore("return_value_discarded") -func run_update() -> void: - #get_cancel_button().disabled = true - #get_ok_button().disabled = true - - await update_progress("Download Release ... [img=24x24]%s[/img]" % GdUnitUiTools.get_spinner()) - await download_release() - await update_progress("Extract update ... [img=24x24]%s[/img]" % GdUnitUiTools.get_spinner()) - var zip_file := temp_dir() + "/update.zip" - var tmp_path := create_temp_dir("update") - var result :Variant = extract_zip(zip_file, tmp_path) - if result == null: - await update_progress("Update failed!") - await get_tree().create_timer(3).timeout - queue_free() - return - - await update_progress("Uninstall GdUnit4 ... [img=24x24]%s[/img]" % GdUnitUiTools.get_spinner()) - disable_gdUnit() - if not _debug_mode: - delete_directory("res://addons/gdUnit4/") - # give editor time to react on deleted files - await get_tree().create_timer(1).timeout - - await update_progress("Install new GdUnit4 version ...") - if _debug_mode: - copy_directory(tmp_path, "res://debug") - else: - copy_directory(tmp_path, "res://") - - await update_progress("New GdUnit version successfully installed, Restarting Godot ...") - await get_tree().create_timer(3).timeout - enable_gdUnit() - hide() - delete_directory("res://addons/.gdunit_update") - restart_godot() - - -func restart_godot() -> void: - prints("Force restart Godot") - EditorInterface.restart_editor(true) - - -@warning_ignore("return_value_discarded") -func enable_gdUnit() -> void: - var enabled_plugins := PackedStringArray() - if ProjectSettings.has_setting("editor_plugins/enabled"): - enabled_plugins = ProjectSettings.get_setting("editor_plugins/enabled") - if not enabled_plugins.has("res://addons/gdUnit4/plugin.cfg"): - enabled_plugins.append("res://addons/gdUnit4/plugin.cfg") - ProjectSettings.set_setting("editor_plugins/enabled", enabled_plugins) - ProjectSettings.save() - - -func disable_gdUnit() -> void: - EditorInterface.set_plugin_enabled("gdUnit4", false) - - -const GDUNIT_TEMP := "user://tmp" - -func temp_dir() -> String: - if not DirAccess.dir_exists_absolute(GDUNIT_TEMP): - @warning_ignore("return_value_discarded") - DirAccess.make_dir_recursive_absolute(GDUNIT_TEMP) - return GDUNIT_TEMP - - -func create_temp_dir(folder_name :String) -> String: - var new_folder := temp_dir() + "/" + folder_name - delete_directory(new_folder) - if not DirAccess.dir_exists_absolute(new_folder): - @warning_ignore("return_value_discarded") - DirAccess.make_dir_recursive_absolute(new_folder) - return new_folder - - -func delete_directory(path :String, only_content := false) -> void: - var dir := DirAccess.open(path) - if dir != null: - @warning_ignore("return_value_discarded") - dir.list_dir_begin() - var file_name := "." - while file_name != "": - file_name = dir.get_next() - if file_name.is_empty() or file_name == "." or file_name == "..": - continue - var next := path + "/" +file_name - if dir.current_is_dir(): - delete_directory(next) - else: - # delete file - var err := dir.remove(next) - if err: - push_error("Delete %s failed: %s" % [next, error_string(err)]) - if not only_content: - var err := dir.remove(path) - if err: - push_error("Delete %s failed: %s" % [path, error_string(err)]) - - -func copy_directory(from_dir :String, to_dir :String) -> bool: - if not DirAccess.dir_exists_absolute(from_dir): - push_error("Source directory not found '%s'" % from_dir) - return false - # check if destination exists - if not DirAccess.dir_exists_absolute(to_dir): - # create it - var err := DirAccess.make_dir_recursive_absolute(to_dir) - if err != OK: - push_error("Can't create directory '%s'. Error: %s" % [to_dir, error_string(err)]) - return false - var source_dir := DirAccess.open(from_dir) - var dest_dir := DirAccess.open(to_dir) - if source_dir != null: - @warning_ignore("return_value_discarded") - source_dir.list_dir_begin() - var next := "." - - while next != "": - next = source_dir.get_next() - if next == "" or next == "." or next == "..": - continue - var source := source_dir.get_current_dir() + "/" + next - var dest := dest_dir.get_current_dir() + "/" + next - if source_dir.current_is_dir(): - @warning_ignore("return_value_discarded") - copy_directory(source + "/", dest) - continue - var err := source_dir.copy(source, dest) - if err != OK: - push_error("Error checked copy file '%s' to '%s'" % [source, dest]) - return false - return true - else: - push_error("Directory not found: " + from_dir) - return false - - -func extract_zip(zip_package :String, dest_path :String) -> Variant: - var zip: ZIPReader = ZIPReader.new() - var err := zip.open(zip_package) - if err != OK: - push_error("Extracting `%s` failed! Please collect the error log and report this. Error Code: %s" % [zip_package, err]) - return null - var zip_entries: PackedStringArray = zip.get_files() - # Get base path and step over archive folder - var archive_path := zip_entries[0] - zip_entries.remove_at(0) - - for zip_entry in zip_entries: - var new_file_path: String = dest_path + "/" + zip_entry.replace(archive_path, "") - if zip_entry.ends_with("/"): - @warning_ignore("return_value_discarded") - DirAccess.make_dir_recursive_absolute(new_file_path) - continue - var file: FileAccess = FileAccess.open(new_file_path, FileAccess.WRITE) - file.store_buffer(zip.read_file(zip_entry)) - @warning_ignore("return_value_discarded") - zip.close() - return dest_path - - -func download_release() -> void: - var zip_file := GdUnitFileAccess.temp_dir() + "/update.zip" - var response :GdUnitUpdateClient.HttpResponse - if _debug_mode: - response = GdUnitUpdateClient.HttpResponse.new(200, PackedByteArray()) - zip_file = "res://update.zip" - else: - response = await _update_client.request_zip_package(_download_url, zip_file) - _update_client.queue_free() - if response.status() != 200: - push_warning("Update information cannot be retrieved from GitHub! \n Error code: %d : %s" % [response.status(), response.response()]) - message_h4("Update failed! Try it later again.", Color.RED) - await get_tree().create_timer(3).timeout - return - - -func _on_confirmed() -> void: - await run_update() - - -func _on_cancel_pressed() -> void: - hide() diff --git a/addons/.gdunit_update/GdUnitUpdate.tscn b/addons/.gdunit_update/GdUnitUpdate.tscn deleted file mode 100644 index c3b7e502..00000000 --- a/addons/.gdunit_update/GdUnitUpdate.tscn +++ /dev/null @@ -1,86 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://2eahgaw88y6q"] - -[ext_resource type="Script" uid="uid://dj7jhsfanwaxl" path="res://addons/.gdunit_update/GdUnitUpdate.gd" id="1"] -[ext_resource type="Texture2D" uid="uid://cwxuep3lbnu3p" path="res://addons/gdUnit4/src/update/assets/progress-background.png" id="2_q6rkd"] - -[sub_resource type="AtlasTexture" id="AtlasTexture_wilsr"] - -[node name="GdUnitUpdate" type="MarginContainer"] -clip_contents = true -custom_minimum_size = Vector2(0, 80) -anchors_preset = 10 -anchor_right = 1.0 -offset_bottom = 80.0 -grow_horizontal = 2 -size_flags_horizontal = 3 -theme_override_constants/margin_left = 10 -theme_override_constants/margin_right = 10 -script = ExtResource("1") - -[node name="VBoxContainer" type="VBoxContainer" parent="."] -layout_mode = 2 - -[node name="Panel" type="Panel" parent="VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 3 - -[node name="message" type="RichTextLabel" parent="VBoxContainer/Panel"] -unique_name_in_owner = true -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -bbcode_enabled = true -text = "aaaaa" -fit_content = true -scroll_active = false -shortcut_keys_enabled = false - -[node name="Panel2" type="Panel" parent="VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 3 - -[node name="progress" type="TextureProgressBar" parent="VBoxContainer/Panel2"] -unique_name_in_owner = true -auto_translate_mode = 2 -clip_contents = true -custom_minimum_size = Vector2(0, 20) -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -localize_numeral_system = false -min_value = 1.0 -max_value = 5.0 -value = 1.0 -rounded = true -allow_greater = true -nine_patch_stretch = true -texture_under = SubResource("AtlasTexture_wilsr") -texture_progress = ExtResource("2_q6rkd") -texture_progress_offset = Vector2(0, 2) -tint_under = Color(0.0235294, 0.145098, 0.168627, 1) -tint_progress = Color(0.288912, 0.233442, 0.533772, 1) - -[node name="PanelContainer" type="MarginContainer" parent="VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 3 - -[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer"] -layout_mode = 2 -theme_override_constants/separation = 10 -alignment = 2 - -[node name="update" type="Button" parent="VBoxContainer/PanelContainer/HBoxContainer"] -layout_mode = 2 -text = "Update" - -[node name="cancel" type="Button" parent="VBoxContainer/PanelContainer/HBoxContainer"] -layout_mode = 2 -text = "Cancel" - -[connection signal="pressed" from="VBoxContainer/PanelContainer/HBoxContainer/cancel" to="." method="_on_cancel_pressed"] diff --git a/addons/gdUnit4/src/ui/settings/GdUnitSettingsDialog.tscn b/addons/gdUnit4/src/ui/settings/GdUnitSettingsDialog.tscn index 6ecdab95..0ecfa65b 100644 --- a/addons/gdUnit4/src/ui/settings/GdUnitSettingsDialog.tscn +++ b/addons/gdUnit4/src/ui/settings/GdUnitSettingsDialog.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=8 format=3 uid="uid://dwgat6j2u77g4"] -[ext_resource type="Script" uid="uid://blpce0ewahptu" path="res://addons/gdUnit4/src/ui/settings/GdUnitSettingsDialog.gd" id="2"] +[ext_resource type="Script" path="res://addons/gdUnit4/src/ui/settings/GdUnitSettingsDialog.gd" id="2"] [ext_resource type="Texture2D" uid="uid://bkh022wwqq7s3" path="res://addons/gdUnit4/src/ui/settings/logo.png" id="3_isfyl"] [ext_resource type="PackedScene" uid="uid://dte0m2endcgtu" path="res://addons/gdUnit4/src/ui/templates/TestSuiteTemplate.tscn" id="4"] [ext_resource type="PackedScene" uid="uid://0xyeci1tqebj" path="res://addons/gdUnit4/src/update/GdUnitUpdateNotify.tscn" id="5_n1jtv"] [ext_resource type="PackedScene" uid="uid://pmnkxrhglak5" path="res://addons/gdUnit4/src/ui/settings/GdUnitInputCapture.tscn" id="5_xu3j8"] -[ext_resource type="Script" uid="uid://b14sutd7w0dx6" path="res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd" id="8_2ggr0"] +[ext_resource type="Script" path="res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd" id="8_2ggr0"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hbbq5"] content_margin_left = 10.0 diff --git a/addons/gdUnit4/src/update/GdMarkDownReader.gd b/addons/gdUnit4/src/update/GdMarkDownReader.gd index 55a8d84f..e03b17d2 100644 --- a/addons/gdUnit4/src/update/GdMarkDownReader.gd +++ b/addons/gdUnit4/src/update/GdMarkDownReader.gd @@ -1,23 +1,29 @@ +@tool extends RefCounted const GdUnitUpdateClient = preload("res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd") -const FONT_H1 := 32 -const FONT_H2 := 28 -const FONT_H3 := 24 -const FONT_H4 := 20 -const FONT_H5 := 16 +const FONT_H1 := 22 +const FONT_H2 := 20 +const FONT_H3 := 18 +const FONT_H4 := 16 +const FONT_H5 := 14 const FONT_H6 := 12 -const HORIZONTAL_RULE := "[img=4000x2]res://addons/gdUnit4/src/update/assets/horizontal-line2.png[/img]\n" -const HEADER_RULE := "[font_size=%d]$1[/font_size]\n" -const HEADER_CENTERED_RULE := "[font_size=%d][center]$1[/center][/font_size]\n" +const HORIZONTAL_RULE := "[img=4000x2]res://addons/gdUnit4/src/update/assets/horizontal-line2.png[/img]" +const HEADER_RULE := "[font_size=%d]$1[/font_size]" +const HEADER_CENTERED_RULE := "[font_size=%d][center]$1[/center][/font_size]" const image_download_folder := "res://addons/gdUnit4/tmp-update/" const exclude_font_size := "\b(?!(?:(font_size))\b)" +var regex_comment := regex("(?m)^$") + var md_replace_patterns := [ + # comments + [regex("(?m)^\\n?\\s*\\s*\\n?"), ""], + # horizontal rules [regex("(?m)^[ ]{0,3}---$"), HORIZONTAL_RULE], [regex("(?m)^[ ]{0,3}___$"), HORIZONTAL_RULE], @@ -50,14 +56,16 @@ var md_replace_patterns := [ #[regex("(\\*)"), "xxx$1xxx"], # extract/compile image references - [regex("!\\[(.*?)\\]\\[(.*?)\\]"), Callable(self, "process_image_references")], + [regex("!\\[(.*?)\\]\\[(.*?)\\]"), process_image_references], # extract images with path and optional tool tip - [regex("!\\[(.*?)\\]\\((.*?)(( )+(.*?))?\\)"), Callable(self, "process_image")], + [regex("!\\[(.*?)\\]\\((.*?)(( )+(.*?))?\\)"), process_image], # links [regex("([!]|)\\[(.+)\\]\\(([^ ]+?)\\)"), "[url={\"url\":\"$3\"}]$2[/url]"], # links with tool tip [regex("([!]|)\\[(.+)\\]\\(([^ ]+?)( \"(.+)\")?\\)"), "[url={\"url\":\"$3\", \"tool_tip\":\"$5\"}]$2[/url]"], + # links to pull request + [regex("(https://.*/?/(\\S+))"), '[url={"url":"$1", "tool_tip":"$1"}]#$2[/url]'], # embeded text [regex("(?m)^[ ]{0,3}>(.*?)$"), "[img=50x14]res://addons/gdUnit4/src/update/assets/embedded.png[/img][i]$1[/i]"], @@ -80,26 +88,31 @@ var md_replace_patterns := [ [regex("~(.*?)~"), "[s]$1[/s]"], # handling lists - # using an image for dots as workaroud because list is not supported checked Godot 3.x + # using an image for dots [regex("(?m)^[ ]{0,1}[*\\-+] (.*)$"), list_replace(0)], [regex("(?m)^[ ]{2,3}[*\\-+] (.*)$"), list_replace(1)], [regex("(?m)^[ ]{4,5}[*\\-+] (.*)$"), list_replace(2)], [regex("(?m)^[ ]{6,7}[*\\-+] (.*)$"), list_replace(3)], [regex("(?m)^[ ]{8,9}[*\\-+] (.*)$"), list_replace(4)], - # code blocks, code blocks looks not like code blocks in richtext - [regex("```(javascript|python|shell|gdscript)([\\s\\S]*?\n)```"), code_block("$2", true)], + # code [regex("``([\\s\\S]*?)``"), code_block("$1")], [regex("`([\\s\\S]*?)`{1,2}"), code_block("$1")], ] +var code_block__patterns := [ + # code blocks, code blocks looks not like code blocks in richtext + [regex("```(javascript|python|shell|gdscript|gd)([\\s\\S]*?\n)```"), code_block("$2", true)], + +] + var _img_replace_regex := RegEx.new() var _image_urls := PackedStringArray() var _on_table_tag := false var _client :GdUnitUpdateClient -func regex(pattern :String) -> RegEx: +static func regex(pattern :String) -> RegEx: var regex_ := RegEx.new() var err := regex_.compile(pattern) if err != OK: @@ -136,15 +149,17 @@ func list_replace(indent :int) -> String: func code_block(replace :String, border :bool = false) -> String: - var cb := "[code][color=aqua][font_size=16]%s[/font_size][/color][/code]" % replace + #Color.DARK_SLATE_GRAY if border: - return "[img=1400x14]res://addons/gdUnit4/src/update/assets/border_top.png[/img]"\ - + "[indent]" + cb + "[/indent]"\ - + "[img=1400x14]res://addons/gdUnit4/src/update/assets/border_bottom.png[/img]\n" - return cb + return """ + [img=1400x14]res://addons/gdUnit4/src/update/assets/border_top.png[/img] + [indent][color=GRAY][font_size=16]%s[/font_size][/color][/indent] + [img=1400x14]res://addons/gdUnit4/src/update/assets/border_bottom.png[/img] + """.dedent() % replace + return "[code][bgcolor=DARK_SLATE_GRAY][color=GRAY][font_size=16]%s[/font_size][/color][/bgcolor][/code]" % replace -func to_bbcode(input :String) -> String: +func convert_text(input :String) -> String: input = process_tables(input) for pattern :Array in md_replace_patterns: @@ -159,6 +174,39 @@ func to_bbcode(input :String) -> String: return input + "\n" +func convert_code_block(input :String) -> String: + for pattern :Array in code_block__patterns: + var regex_ :RegEx = pattern[0] + var bb_replace :Variant = pattern[1] + if bb_replace is Callable: + @warning_ignore("unsafe_method_access") + input = await bb_replace.call(regex_, input) + else: + @warning_ignore("unsafe_cast") + input = regex_.sub(input, bb_replace as String, true) + return input + "\n" + + +func to_bbcode(input: String) -> String: + var re := regex("(?m)```[\\s\\S]*?```") + var current_pos := 0 + var as_bbcode := "" + + # we split by code blocks to handle this blocks customized + for result in re.search_all(input): + # Add text before code block + if result.get_start() > current_pos: + as_bbcode += await convert_text(input.substr(current_pos, result.get_start() - current_pos)) + # Add code block + as_bbcode += await convert_code_block(result.get_string()) + current_pos = result.get_end() + + # Add remaining text after last code block + if current_pos < input.length(): + as_bbcode += await convert_text(input.substr(current_pos)) + return as_bbcode + + func process_tables(input: String) -> String: var bbcode := PackedStringArray() var lines: Array[String] = Array(input.split("\n") as Array, TYPE_STRING, "", null) @@ -273,6 +321,8 @@ func extract_cells(line :String, bold := false) -> String: func process_image_references(p_regex :RegEx, p_input :String) -> String: + #return p_input + # exists references? var matches := p_regex.search_all(p_input) if matches.is_empty(): @@ -303,6 +353,7 @@ func process_image_references(p_regex :RegEx, p_input :String) -> String: @warning_ignore("return_value_discarded") func process_image(p_regex :RegEx, p_input :String) -> String: + #return p_input var to_replace := PackedStringArray() var tool_tips := PackedStringArray() # find all matches diff --git a/addons/gdUnit4/src/update/GdUnitUpdate.gd b/addons/gdUnit4/src/update/GdUnitUpdate.gd index 5a3d588f..1b492fe8 100644 --- a/addons/gdUnit4/src/update/GdUnitUpdate.gd +++ b/addons/gdUnit4/src/update/GdUnitUpdate.gd @@ -12,7 +12,7 @@ const GDUNIT_TEMP := "user://tmp" @onready var _spinner_img := GdUnitUiTools.get_spinner() -var _debug_mode := true +var _debug_mode := false var _update_client :GdUnitUpdateClient var _download_url :String diff --git a/addons/gdUnit4/src/update/GdUnitUpdate.tscn b/addons/gdUnit4/src/update/GdUnitUpdate.tscn index c42ad0b0..20d60b76 100644 --- a/addons/gdUnit4/src/update/GdUnitUpdate.tscn +++ b/addons/gdUnit4/src/update/GdUnitUpdate.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=6 format=3 uid="uid://2eahgaw88y6q"] -[ext_resource type="Script" uid="uid://dj7jhsfanwaxl" path="res://addons/gdUnit4/src/update/GdUnitUpdate.gd" id="1"] +[ext_resource type="Script" path="res://addons/gdUnit4/src/update/GdUnitUpdate.gd" id="1"] [sub_resource type="Gradient" id="Gradient_wilsr"] colors = PackedColorArray(0.151276, 0.151276, 0.151276, 1, 1, 1, 1, 1) diff --git a/addons/gdUnit4/src/update/GdUnitUpdateClient.gd b/addons/gdUnit4/src/update/GdUnitUpdateClient.gd index 91d2009c..f663f14e 100644 --- a/addons/gdUnit4/src/update/GdUnitUpdateClient.gd +++ b/addons/gdUnit4/src/update/GdUnitUpdateClient.gd @@ -21,7 +21,6 @@ class HttpResponse: if _http_status != 200: return _body.get_string_from_utf8() - var test_json_conv := JSON.new() @warning_ignore("return_value_discarded") var error := test_json_conv.parse(_body.get_string_from_utf8()) diff --git a/addons/gdUnit4/src/update/GdUnitUpdateNotify.gd b/addons/gdUnit4/src/update/GdUnitUpdateNotify.gd index 46044e01..f4ae9aca 100644 --- a/addons/gdUnit4/src/update/GdUnitUpdateNotify.gd +++ b/addons/gdUnit4/src/update/GdUnitUpdateNotify.gd @@ -17,43 +17,44 @@ const GdUnitUpdateProgress = preload("res://addons/gdUnit4/src/update/GdUnitUpda var _debug_mode := false var _patcher := GdUnitPatcher.new() var _current_version := GdUnit4Version.current() -var _download_zip_url := "" func _ready() -> void: _update_button.set_disabled(false) _md_reader.set_http_client(_update_client) @warning_ignore("return_value_discarded") - GdUnitFonts.init_fonts(_content) + #GdUnitFonts.init_fonts(_content) _update_progress.set_visible(false) _update_progress.hidden.connect(func() -> void: _update_button.set_disabled(false) ) -func request_releases() -> void: +func request_releases() -> bool: if _debug_mode: _update_progress._debug_mode = _debug_mode - _header.text = "A new version 'v4.1.0_debug' is available" - _download_zip_url = "invalid" + _header.text = "A new version 'v4.4.4' is available" _update_button.set_disabled(false) - return + return true var response :GdUnitUpdateClient.HttpResponse = await _update_client.request_latest_version() if response.status() != 200: _header.text = "Update information cannot be retrieved from GitHub!" message_h4("\n\nError: %s" % response.response(), Color.INDIAN_RED) - return + return false var latest_version := _update_client.extract_latest_version(response) # if same version exit here no update need if latest_version.is_greater(_current_version): _patcher.scan(_current_version) _header.text = "A new version '%s' is available" % latest_version - _download_zip_url = extract_zip_url(response) + var download_zip_url := extract_zip_url(response) + _update_progress.setup(_update_client, download_zip_url) _update_button.set_disabled(false) + return true else: _header.text = "No update is available." _update_button.set_disabled(true) + return false func _colored(message_: String, color: Color) -> String: @@ -83,7 +84,8 @@ func show_update() -> void: _update_button.set_disabled(true) return - await request_releases() + if not await request_releases(): + return _update_button.set_disabled(true) prints("Scan for GdUnit4 Update ...") @@ -92,8 +94,8 @@ func show_update() -> void: var content: String if _debug_mode: - await get_tree().create_timer(2).timeout - var template := FileAccess.open("res://addons/gdUnit4/test/update/resources/markdown.txt", FileAccess.READ).get_as_text() + await get_tree().create_timer(.2).timeout + var template := FileAccess.open("res://addons/gdUnit4/test/update/resources/http_response_releases.txt", FileAccess.READ).get_as_text() content = await _md_reader.to_bbcode(template) else: var response :GdUnitUpdateClient.HttpResponse = await _update_client.request_releases() @@ -120,9 +122,13 @@ func extract_releases(response: GdUnitUpdateClient.HttpResponse, current_version await get_tree().process_frame var result := "" for release :Dictionary in response.response(): - if GdUnit4Version.parse(str(release["tag_name"])).equals(current_version): + var release_version := str(release["tag_name"]) + if GdUnit4Version.parse(release_version).equals(current_version): break - var release_description: String = release["body"] + var release_description := _colored("

GdUnit Release %s

" % release_version, Color.CORNFLOWER_BLUE) + release_description += "\n" + release_description += release["body"] + release_description += "\n\n" result += await _md_reader.to_bbcode(release_description) return result diff --git a/addons/gdUnit4/src/update/GdUnitUpdateNotify.tscn b/addons/gdUnit4/src/update/GdUnitUpdateNotify.tscn index bc311a95..416402aa 100644 --- a/addons/gdUnit4/src/update/GdUnitUpdateNotify.tscn +++ b/addons/gdUnit4/src/update/GdUnitUpdateNotify.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://0xyeci1tqebj"] -[ext_resource type="Script" uid="uid://dq05m3x5da3sf" path="res://addons/gdUnit4/src/update/GdUnitUpdateNotify.gd" id="1_112wo"] -[ext_resource type="Script" uid="uid://b14sutd7w0dx6" path="res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd" id="2_18asx"] +[ext_resource type="Script" path="res://addons/gdUnit4/src/update/GdUnitUpdateNotify.gd" id="1_112wo"] +[ext_resource type="Script" path="res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd" id="2_18asx"] [ext_resource type="PackedScene" uid="uid://2eahgaw88y6q" path="res://addons/gdUnit4/src/update/GdUnitUpdate.tscn" id="3_x87h6"] [node name="Control" type="MarginContainer"] diff --git a/addons/gdUnit4/src/update/assets/progress-background.png b/addons/gdUnit4/src/update/assets/progress-background.png deleted file mode 100644 index 670013a769b778a9e96c06d1d53634f147c6d85e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1047 zcmeAS@N?(olHy`uVBq!ia0y~yV5tMLl{wgePnv;&d5x!wV@O5Z+q=HqGNB@D4=k_B{=eW; zm6qh=#9^p*Ou$6KLt*wGLHhtfalM!w1rMDH6gxar1PUG=>eUYaCt(~rRb#8nj9JlF z?{0rrJMTilwUcXqi{<;BKQejw|B~t}r}x{1Jbv=zex29$Js;fc165}-UiCQ1BN=EZ z$#}EN-T&XWjzet~J5HResy*fX$CCeL(aWWBX0B-yCQmstL2!emQIp}L!^i9AzUQ$l zWZ1kVZvUI*CEZV3>!du=7|sNFrJdktusO=k|G(rZ)0-P+dXLI#FZsU|>rS<2+@QTP zt*wXQ#@@?DO7HA{IDcdgXxt_n|Hq_vdR2qek`$oaiQqfc|I3f^JFwm=yX*gQR@y~> zhABF##wjcg^B%qXE8ZoaaBW*z=h;8o-dG*wZ#W~N29h%C<5mB|JVFrT+tB!obNzD-CS!2%SXr7&Ig&2aeH!|*L9QAbxaFV zG-oO*Gkg-cp8szJNO7+`L)#{xF?~DA996nSI2~APu5vdl1QH8m3V+@z?~-re+H#lWsDH&u_7#p$A1z&dU#m{Re4dxtg4qjx zaQ>go{d1yZjsr;c#Dty)TP^BdOS>~JU|MWe_iM?9WBdW^()J8bI}V?Ye;)d0#X<(N zMJIaYXEJUObj|q#jIjSlUtJ1c=h7fml55{1;A_tiumu#^43S+|KThwGPdjjCYxseV`FmA8FS9|*r||CYpS%pEpj68^VeyUlT40QT zHLb5=yrQ)0qddc_f+)5*Ul|p=H`f1{7%jDcDOl$LH&25VG?B?@)G@5O;IrZJ&24`f z94>-g_e3-7I54cGfKn1(pt!QA3jTQ5$6}?ysU*XHr{i8bP0l+XkKI|<7$ diff --git a/addons/gdUnit4/src/update/assets/progress-background.png.import b/addons/gdUnit4/src/update/assets/progress-background.png.import deleted file mode 100644 index 3f105e80..00000000 --- a/addons/gdUnit4/src/update/assets/progress-background.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://cwxuep3lbnu3p" -path="res://.godot/imported/progress-background.png-20022b3af2be583c006365edbc69d914.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://addons/gdUnit4/src/update/assets/progress-background.png" -dest_files=["res://.godot/imported/progress-background.png-20022b3af2be583c006365edbc69d914.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -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/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 diff --git a/addons/gdUnit4/test/update/bbcodeView.gd b/addons/gdUnit4/test/update/bbcodeView.gd index 8229682e..2c1115ee 100644 --- a/addons/gdUnit4/test/update/bbcodeView.gd +++ b/addons/gdUnit4/test/update/bbcodeView.gd @@ -4,8 +4,8 @@ const GdUnitTools := preload("res://addons/gdUnit4/src/core/GdUnitTools.gd") const GdMarkDownReader := preload("res://addons/gdUnit4/src/update/GdMarkDownReader.gd") const GdUnitUpdateClient := preload("res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd") -@onready var _input :TextEdit = $HSplitContainer/TextEdit -@onready var _text :RichTextLabel = $HSplitContainer/RichTextLabel +@onready var _input: TextEdit = $HSplitContainer/TextEdit +@onready var _text: RichTextLabel = $HSplitContainer/RichTextLabel @onready var _update_client :GdUnitUpdateClient = $GdUnitUpdateClient @@ -14,8 +14,10 @@ var _md_reader := GdMarkDownReader.new() func _ready() -> void: _md_reader.set_http_client(_update_client) - var source := GdUnitFileAccess.resource_as_string("res://addons/gdUnit4/test/update/resources/markdown_example.txt") + #GdUnitFonts.init_fonts(_text) + var source := GdUnitFileAccess.resource_as_string("res://addons/gdUnit4/test/update/resources/http_response_releases.txt") _input.text = source + await set_bbcode(source) @@ -31,18 +33,16 @@ func _on_TextEdit_text_changed() -> void: func _on_RichTextLabel_meta_clicked(meta :String) -> void: - var properties :Variant = str_to_var(meta) - prints("meta_clicked", properties) + var properties: Dictionary = str_to_var(meta) if properties.has("url"): - OS.shell_open(properties.get("url")) + OS.shell_open(str(properties.get("url"))) func _on_RichTextLabel_meta_hover_started(meta :String) -> void: - var properties :Variant = str_to_var(meta) - prints("hover_started", properties) + var properties: Dictionary = str_to_var(meta) if properties.has("tool_tip"): - _text.set_tooltip(properties.get("tool_tip")) + _text.set_tooltip_text(str(properties.get("tool_tip"))) func _on_RichTextLabel_meta_hover_ended(_meta :String) -> void: - _text.set_tooltip("") + _text.set_tooltip_text("") diff --git a/addons/gdUnit4/test/update/bbcodeView.tscn b/addons/gdUnit4/test/update/bbcodeView.tscn index e096c514..2c751ed5 100644 --- a/addons/gdUnit4/test/update/bbcodeView.tscn +++ b/addons/gdUnit4/test/update/bbcodeView.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://c1rwx6anh3u3m"] -[ext_resource type="Script" path="res://addons/gdUnit4/test/update/bbcodeView.gd" id="1"] -[ext_resource type="Script" path="res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd" id="6"] +[ext_resource type="Script" uid="uid://cdp6c2sdw2075" path="res://addons/gdUnit4/test/update/bbcodeView.gd" id="1"] +[ext_resource type="Script" uid="uid://b14sutd7w0dx6" path="res://addons/gdUnit4/src/update/GdUnitUpdateClient.gd" id="6"] [node name="Control" type="Control"] layout_mode = 3 diff --git a/addons/gdUnit4/test/update/resources/http_response_releases.txt b/addons/gdUnit4/test/update/resources/http_response_releases.txt new file mode 100644 index 00000000..ad38a6e8 --- /dev/null +++ b/addons/gdUnit4/test/update/resources/http_response_releases.txt @@ -0,0 +1,164 @@ +Scan for GdUnit4 Update ... +[color=#6495edff]

GdUnit Release v4.4.3

[/color] +# Hotfix memory leaks on test execution + +## What's Changed + +* GD-598: Fixing memory leaks on test execution by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/599 + + +**Full Changelog**: https://github.com/MikeSchulze/gdUnit4/compare/v4.4.2...v4.4.3 + + +[color=#6495edff]

GdUnit Release v4.4.2

[/color] + + +## What's Changed +### Bug Fixes +* GD-592: Fixes, the detection of parameterized test data changes in `TestDiscoveryGuard` to notify the test explorer and update the structure. by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/593 +* GD-594: Fixes, mock fails on class with parameter getter setter by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/595 +* GD-596: Fixes, run test via CMD line is broken when use skipp command option by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/597 + +### Other Changes +* GD-590: Fixes, HTML test report footer overlapping in Firefox by @Eggbertx in https://github.com/MikeSchulze/gdUnit4/pull/589 + + +**Full Changelog**: https://github.com/MikeSchulze/gdUnit4/compare/v4.4.1...v4.4.2 + + +[color=#6495edff]

GdUnit Release v4.4.1

[/color] + + +## What's Changed +### Improvements +* GD-579: Minimize warnings of testsuite resource loading by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/587 +* GD-579: `Part1:` Minimize `unsafe_call_argument` warnings by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/580 +* GD-579: `Part2`: Minimize `return_value_discarded` warnings by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/582 +* GD-579: `Part3:` Minimize `unsafe_property_access` warnings by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/583 +* GD-579: `Part4:` Minimize `unsafe_method_access` warnings by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/584 +* GD-579: `Part5:` Minimize `unsafe_cast` warnings by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/586 + + +**Full Changelog**: https://github.com/MikeSchulze/gdUnit4/compare/v4.4.0...v4.4.1 + + +[color=#6495edff]

GdUnit Release v4.4.0

[/color] +GdUnit4 v4.4.0 + + + +## What's Changed +* Introduction of flaky test detection, automatically executed again if flaky test detection is enabled. +* Added touchscreen support to the SceneRunner. +* HTML report look & feel redesign + +### Improvements +* GD-220: Add support for flaky test handling and retrying their execution by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/558 +![image](https://github.com/user-attachments/assets/fe90f750-e9c6-4ff9-b892-2885f00fd71c) +* GD-554: Adding support for touch screen input event testing to `GdUnitSceneRunner` by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/556 +```gd +## Simulates a screen touch is pressed.[br] +## [member index] : The touch index in the case of a multi-touch event.[br] +## [member position] : The position to touch the screen.[br] +## [member double_tap] : If true, the touch's state is a double tab. +@warning_ignore("unused_parameter") +func simulate_screen_touch_pressed(index :int, position :Vector2, double_tap := false) -> GdUnitSceneRunner: + + +## Simulates a screen touch is press.[br] +## [member index] : The touch index in the case of a multi-touch event.[br] +## [member position] : The position to touch the screen.[br] +## [member double_tap] : If true, the touch's state is a double tab. +@warning_ignore("unused_parameter") +func simulate_screen_touch_press(index :int, position :Vector2, double_tap := false) -> GdUnitSceneRunner: + + +## Simulates a screen touch is released.[br] +## [member index] : The touch index in the case of a multi-touch event.[br] +## [member double_tap] : If true, the touch's state is a double tab. +@warning_ignore("unused_parameter") +func simulate_screen_touch_release(index :int, double_tap := false) -> GdUnitSceneRunner: + + +## Simulates a touch screen drag&drop to the relative coordinates (offset).[br] +## [color=yellow]You must use [b]await[/b] to wait until the simulated drag&drop is complete.[/color][br] +## [br] +## [member index] : The touch index in the case of a multi-touch event.[br] +## [member relative] : The relative position, indicating the drag&drop position offset.[br] +## [member time] : The time to move to the relative position in seconds (default is 1 second).[br] +## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br] +## [codeblock] +## func test_touch_drag_drop(): +## var runner = scene_runner("res://scenes/simple_scene.tscn") +## # start drag at position 50,50 +## runner.simulate_screen_touch_drag_begin(1, Vector2(50, 50)) +## # and drop it at final at 150,50 relative (50,50 + 100,0) +## await runner.simulate_screen_touch_drag_relative(1, Vector2(100,0)) +## [/codeblock] +@warning_ignore("unused_parameter") +func simulate_screen_touch_drag_relative(index :int, relative: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner: + + +## Simulates a touch screen drop to the absolute coordinates (offset).[br] +## [color=yellow]You must use [b]await[/b] to wait until the simulated drop is complete.[/color][br] +## [br] +## [member index] : The touch index in the case of a multi-touch event.[br] +## [member position] : The final position, indicating the drop position.[br] +## [member time] : The time to move to the final position in seconds (default is 1 second).[br] +## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br] +## [codeblock] +## func test_touch_drag_drop(): +## var runner = scene_runner("res://scenes/simple_scene.tscn") +## # start drag at position 50,50 +## runner.simulate_screen_touch_drag_begin(1, Vector2(50, 50)) +## # and drop it at 100,50 +## await runner.simulate_screen_touch_drag_absolute(1, Vector2(100,50)) +## [/codeblock] +@warning_ignore("unused_parameter") +func simulate_screen_touch_drag_absolute(index :int, position: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner: + + +## Simulates a touch screen drop&drop to the absolute coordinates (offset).[br] +## [color=yellow]You must use [b]await[/b] to wait until the simulated drop is complete.[/color][br] +## [br] +## [member index] : The touch index in the case of a multi-touch event.[br] +## [member position] : The drag start position, indicating the drag position.[br] +## [member drop_position] : The drop position, indicating the drop position.[br] +## [member time] : The time to move to the final position in seconds (default is 1 second).[br] +## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br] +## [codeblock] +## func test_touch_drag_drop(): +## var runner = scene_runner("res://scenes/simple_scene.tscn") +## # start drag at position 50,50 and drop it at 100,50 +## await runner.simulate_screen_touch_drag_drop(1, Vector2(50, 50), Vector2(100,50)) +## [/codeblock] +@warning_ignore("unused_parameter") +func simulate_screen_touch_drag_drop(index :int, position: Vector2, drop_position: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner: + + +## Simulates a touch screen drag event to given position.[br] +## [member index] : The touch index in the case of a multi-touch event.[br] +## [member position] : The drag start position, indicating the drag position.[br] +@warning_ignore("unused_parameter") +func simulate_screen_touch_drag(index :int, position: Vector2) -> GdUnitSceneRunner: + + +## Returns the actual position of the touch drag postion by given index +## [member index] : The touch index in the case of a multi-touch event.[br] +@warning_ignore("unused_parameter") +func get_screen_touch_drag_position(index: int) -> Vector2: +``` +* GD-566: Update HTML report page look & feel by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/567 +![image](https://github.com/user-attachments/assets/141b5527-168a-4745-91ce-2c8d9112cda1) + + +### Bug Fixes +* GD-549: Fix, error if GdUnit4 inspector tab is floating by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/552 +* GD-559: Fix, inspector directory collapse toggling by @poohcom1 in https://github.com/MikeSchulze/gdUnit4/pull/560 +* GD-563: Fix, parameterized test not executed when using typed arrays end ends with invalid success state by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/572 +* GD-573: Fixed the inspector double-click, inherited tests to jump to the script where the test are located by @MikeSchulze in https://github.com/MikeSchulze/gdUnit4/pull/574 + +## New Contributors +* @poohcom1 made their first contribution in https://github.com/MikeSchulze/gdUnit4/pull/560 + +**Full Changelog**: https://github.com/MikeSchulze/gdUnit4/compare/v4.3.4...v4.4.0 diff --git a/project.godot b/project.godot index b7aa5702..69b226ae 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="gdUnit4" config/tags=PackedStringArray("addon", "godot4", "testing") -config/features=PackedStringArray("4.4", "C#") +config/features=PackedStringArray("4.3", "C#") config/icon="res://icon.png" [audio]