From e127ad39e742396030352240d829bc903b1d4464 Mon Sep 17 00:00:00 2001 From: Sophia Pearson Date: Mon, 3 Oct 2022 22:22:50 +0200 Subject: godot: inital Godot 4 migration --- addons/gut/gui/BottomPanelShortcuts.gd | 82 ----- addons/gut/gui/BottomPanelShortcuts.tscn | 232 ------------ addons/gut/gui/GutBottomPanel.gd | 370 ------------------- addons/gut/gui/GutBottomPanel.tscn | 385 ------------------- addons/gut/gui/GutRunner.gd | 95 ----- addons/gut/gui/GutRunner.tscn | 9 - addons/gut/gui/GutSceneTheme.tres | 11 - addons/gut/gui/OutputText.gd | 291 --------------- addons/gut/gui/OutputText.tscn | 123 ------- addons/gut/gui/RunAtCursor.gd | 153 -------- addons/gut/gui/RunAtCursor.tscn | 80 ---- addons/gut/gui/RunResults.gd | 509 -------------------------- addons/gut/gui/RunResults.tscn | 165 --------- addons/gut/gui/Settings.tscn | 7 - addons/gut/gui/ShortcutButton.gd | 164 --------- addons/gut/gui/ShortcutButton.tscn | 80 ---- addons/gut/gui/arrow.png | 3 - addons/gut/gui/arrow.png.import | 35 -- addons/gut/gui/gut_config_gui.gd | 411 --------------------- addons/gut/gui/play.png | 3 - addons/gut/gui/play.png.import | 35 -- addons/gut/gui/script_text_editor_controls.gd | 230 ------------ 22 files changed, 3473 deletions(-) delete mode 100644 addons/gut/gui/BottomPanelShortcuts.gd delete mode 100644 addons/gut/gui/BottomPanelShortcuts.tscn delete mode 100644 addons/gut/gui/GutBottomPanel.gd delete mode 100644 addons/gut/gui/GutBottomPanel.tscn delete mode 100644 addons/gut/gui/GutRunner.gd delete mode 100644 addons/gut/gui/GutRunner.tscn delete mode 100644 addons/gut/gui/GutSceneTheme.tres delete mode 100644 addons/gut/gui/OutputText.gd delete mode 100644 addons/gut/gui/OutputText.tscn delete mode 100644 addons/gut/gui/RunAtCursor.gd delete mode 100644 addons/gut/gui/RunAtCursor.tscn delete mode 100644 addons/gut/gui/RunResults.gd delete mode 100644 addons/gut/gui/RunResults.tscn delete mode 100644 addons/gut/gui/Settings.tscn delete mode 100644 addons/gut/gui/ShortcutButton.gd delete mode 100644 addons/gut/gui/ShortcutButton.tscn delete mode 100644 addons/gut/gui/arrow.png delete mode 100644 addons/gut/gui/arrow.png.import delete mode 100644 addons/gut/gui/gut_config_gui.gd delete mode 100644 addons/gut/gui/play.png delete mode 100644 addons/gut/gui/play.png.import delete mode 100644 addons/gut/gui/script_text_editor_controls.gd (limited to 'addons/gut/gui') diff --git a/addons/gut/gui/BottomPanelShortcuts.gd b/addons/gut/gui/BottomPanelShortcuts.gd deleted file mode 100644 index 86fbf8d..0000000 --- a/addons/gut/gui/BottomPanelShortcuts.gd +++ /dev/null @@ -1,82 +0,0 @@ -tool -extends WindowDialog - -onready var _ctrls = { - run_all = $Layout/CRunAll/ShortcutButton, - run_current_script = $Layout/CRunCurrentScript/ShortcutButton, - run_current_inner = $Layout/CRunCurrentInner/ShortcutButton, - run_current_test = $Layout/CRunCurrentTest/ShortcutButton, - panel_button = $Layout/CPanelButton/ShortcutButton, -} - -func _ready(): - for key in _ctrls: - var sc_button = _ctrls[key] - sc_button.connect('start_edit', self, '_on_edit_start', [sc_button]) - sc_button.connect('end_edit', self, '_on_edit_end') - - - # show dialog when running scene from editor. - if(get_parent() == get_tree().root): - popup_centered() - -# ------------ -# Events -# ------------ -func _on_Hide_pressed(): - hide() - -func _on_edit_start(which): - for key in _ctrls: - var sc_button = _ctrls[key] - if(sc_button != which): - sc_button.disable_set(true) - sc_button.disable_clear(true) - -func _on_edit_end(): - for key in _ctrls: - var sc_button = _ctrls[key] - sc_button.disable_set(false) - sc_button.disable_clear(false) - -# ------------ -# Public -# ------------ -func get_run_all(): - return _ctrls.run_all.get_shortcut() - -func get_run_current_script(): - return _ctrls.run_current_script.get_shortcut() - -func get_run_current_inner(): - return _ctrls.run_current_inner.get_shortcut() - -func get_run_current_test(): - return _ctrls.run_current_test.get_shortcut() - -func get_panel_button(): - return _ctrls.panel_button.get_shortcut() - - -func save_shortcuts(path): - var f = ConfigFile.new() - - f.set_value('main', 'run_all', _ctrls.run_all.get_shortcut()) - f.set_value('main', 'run_current_script', _ctrls.run_current_script.get_shortcut()) - f.set_value('main', 'run_current_inner', _ctrls.run_current_inner.get_shortcut()) - f.set_value('main', 'run_current_test', _ctrls.run_current_test.get_shortcut()) - f.set_value('main', 'panel_button', _ctrls.panel_button.get_shortcut()) - - f.save(path) - - -func load_shortcuts(path): - var emptyShortcut = ShortCut.new() - var f = ConfigFile.new() - f.load(path) - - _ctrls.run_all.set_shortcut(f.get_value('main', 'run_all', emptyShortcut)) - _ctrls.run_current_script.set_shortcut(f.get_value('main', 'run_current_script', emptyShortcut)) - _ctrls.run_current_inner.set_shortcut(f.get_value('main', 'run_current_inner', emptyShortcut)) - _ctrls.run_current_test.set_shortcut(f.get_value('main', 'run_current_test', emptyShortcut)) - _ctrls.panel_button.set_shortcut(f.get_value('main', 'panel_button', emptyShortcut)) diff --git a/addons/gut/gui/BottomPanelShortcuts.tscn b/addons/gut/gui/BottomPanelShortcuts.tscn deleted file mode 100644 index 5e2e5d9..0000000 --- a/addons/gut/gui/BottomPanelShortcuts.tscn +++ /dev/null @@ -1,232 +0,0 @@ -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://addons/gut/gui/ShortcutButton.tscn" type="PackedScene" id=1] -[ext_resource path="res://addons/gut/gui/BottomPanelShortcuts.gd" type="Script" id=2] - -[node name="BottomPanelShortcuts" type="WindowDialog"] -visible = true -anchor_right = 0.234 -anchor_bottom = 0.328 -margin_right = 195.384 -margin_bottom = 62.2 -rect_min_size = Vector2( 435, 305 ) -popup_exclusive = true -window_title = "GUT Shortcuts" -resizable = true -script = ExtResource( 2 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Layout" type="VBoxContainer" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = 5.0 -margin_right = -5.0 -margin_bottom = 2.0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="TopPad" type="CenterContainer" parent="Layout"] -margin_right = 425.0 -margin_bottom = 5.0 -rect_min_size = Vector2( 0, 5 ) - -[node name="Label2" type="Label" parent="Layout"] -margin_top = 9.0 -margin_right = 425.0 -margin_bottom = 29.0 -rect_min_size = Vector2( 0, 20 ) -text = "Always Active" -align = 1 -valign = 1 -autowrap = true - -[node name="ColorRect" type="ColorRect" parent="Layout/Label2"] -show_behind_parent = true -anchor_right = 1.0 -anchor_bottom = 1.0 -color = Color( 0, 0, 0, 0.196078 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="CPanelButton" type="HBoxContainer" parent="Layout"] -margin_top = 33.0 -margin_right = 425.0 -margin_bottom = 58.0 - -[node name="Label" type="Label" parent="Layout/CPanelButton"] -margin_right = 138.0 -margin_bottom = 25.0 -rect_min_size = Vector2( 50, 0 ) -size_flags_vertical = 7 -text = "Show/Hide GUT Panel" -valign = 1 - -[node name="ShortcutButton" parent="Layout/CPanelButton" instance=ExtResource( 1 )] -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 142.0 -margin_right = 425.0 -margin_bottom = 25.0 -size_flags_horizontal = 3 - -[node name="GutPanelPad" type="CenterContainer" parent="Layout"] -margin_top = 62.0 -margin_right = 425.0 -margin_bottom = 67.0 -rect_min_size = Vector2( 0, 5 ) - -[node name="Label" type="Label" parent="Layout"] -margin_top = 71.0 -margin_right = 425.0 -margin_bottom = 91.0 -rect_min_size = Vector2( 0, 20 ) -text = "Only Active When GUT Panel Shown" -align = 1 -valign = 1 -autowrap = true - -[node name="ColorRect2" type="ColorRect" parent="Layout/Label"] -show_behind_parent = true -anchor_right = 1.0 -anchor_bottom = 1.0 -color = Color( 0, 0, 0, 0.196078 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="TopPad2" type="CenterContainer" parent="Layout"] -margin_top = 95.0 -margin_right = 425.0 -margin_bottom = 100.0 -rect_min_size = Vector2( 0, 5 ) - -[node name="CRunAll" type="HBoxContainer" parent="Layout"] -margin_top = 104.0 -margin_right = 425.0 -margin_bottom = 129.0 - -[node name="Label" type="Label" parent="Layout/CRunAll"] -margin_right = 50.0 -margin_bottom = 25.0 -rect_min_size = Vector2( 50, 0 ) -size_flags_vertical = 7 -text = "Run All" -valign = 1 - -[node name="ShortcutButton" parent="Layout/CRunAll" instance=ExtResource( 1 )] -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 54.0 -margin_right = 425.0 -margin_bottom = 25.0 -size_flags_horizontal = 3 - -[node name="CRunCurrentScript" type="HBoxContainer" parent="Layout"] -margin_top = 133.0 -margin_right = 425.0 -margin_bottom = 158.0 - -[node name="Label" type="Label" parent="Layout/CRunCurrentScript"] -margin_right = 115.0 -margin_bottom = 25.0 -rect_min_size = Vector2( 50, 0 ) -size_flags_vertical = 7 -text = "Run Current Script" -valign = 1 - -[node name="ShortcutButton" parent="Layout/CRunCurrentScript" instance=ExtResource( 1 )] -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 119.0 -margin_right = 425.0 -margin_bottom = 25.0 -size_flags_horizontal = 3 - -[node name="CRunCurrentInner" type="HBoxContainer" parent="Layout"] -margin_top = 162.0 -margin_right = 425.0 -margin_bottom = 187.0 - -[node name="Label" type="Label" parent="Layout/CRunCurrentInner"] -margin_right = 150.0 -margin_bottom = 25.0 -rect_min_size = Vector2( 50, 0 ) -size_flags_vertical = 7 -text = "Run Current Inner Class" -valign = 1 - -[node name="ShortcutButton" parent="Layout/CRunCurrentInner" instance=ExtResource( 1 )] -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 154.0 -margin_right = 425.0 -margin_bottom = 25.0 -size_flags_horizontal = 3 - -[node name="CRunCurrentTest" type="HBoxContainer" parent="Layout"] -margin_top = 191.0 -margin_right = 425.0 -margin_bottom = 216.0 - -[node name="Label" type="Label" parent="Layout/CRunCurrentTest"] -margin_right = 106.0 -margin_bottom = 25.0 -rect_min_size = Vector2( 50, 0 ) -size_flags_vertical = 7 -text = "Run Current Test" -valign = 1 - -[node name="ShortcutButton" parent="Layout/CRunCurrentTest" instance=ExtResource( 1 )] -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 110.0 -margin_right = 425.0 -margin_bottom = 25.0 -size_flags_horizontal = 3 - -[node name="CenterContainer2" type="CenterContainer" parent="Layout"] -margin_top = 220.0 -margin_right = 425.0 -margin_bottom = 241.0 -rect_min_size = Vector2( 0, 5 ) -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="ShiftDisclaimer" type="Label" parent="Layout"] -margin_top = 245.0 -margin_right = 425.0 -margin_bottom = 259.0 -text = "\"Shift\" cannot be the only modifier for a shortcut." -align = 2 -autowrap = true - -[node name="HBoxContainer" type="HBoxContainer" parent="Layout"] -margin_top = 263.0 -margin_right = 425.0 -margin_bottom = 293.0 - -[node name="CenterContainer" type="CenterContainer" parent="Layout/HBoxContainer"] -margin_right = 361.0 -margin_bottom = 30.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="Hide" type="Button" parent="Layout/HBoxContainer"] -margin_left = 365.0 -margin_right = 425.0 -margin_bottom = 30.0 -rect_min_size = Vector2( 60, 30 ) -text = "Close" - -[node name="BottomPad" type="CenterContainer" parent="Layout"] -margin_top = 297.0 -margin_right = 425.0 -margin_bottom = 307.0 -rect_min_size = Vector2( 0, 10 ) -size_flags_horizontal = 3 - -[connection signal="pressed" from="Layout/HBoxContainer/Hide" to="." method="_on_Hide_pressed"] diff --git a/addons/gut/gui/GutBottomPanel.gd b/addons/gut/gui/GutBottomPanel.gd deleted file mode 100644 index e7b5037..0000000 --- a/addons/gut/gui/GutBottomPanel.gd +++ /dev/null @@ -1,370 +0,0 @@ -tool -extends Control - -const RUNNER_JSON_PATH = 'res://.gut_editor_config.json' -const RESULT_FILE = 'user://.gut_editor.bbcode' -const RESULT_JSON = 'user://.gut_editor.json' -const SHORTCUTS_PATH = 'res://.gut_editor_shortcuts.cfg' - -var TestScript = load('res://addons/gut/test.gd') -var GutConfigGui = load('res://addons/gut/gui/gut_config_gui.gd') -var ScriptTextEditors = load('res://addons/gut/gui/script_text_editor_controls.gd') - -var _interface = null; -var _is_running = false; -var _gut_config = load('res://addons/gut/gut_config.gd').new() -var _gut_config_gui = null -var _gut_plugin = null -var _light_color = Color(0, 0, 0, .5) -var _panel_button = null -var _last_selected_path = null - - -onready var _ctrls = { - output = $layout/RSplit/CResults/Tabs/OutputText.get_rich_text_edit(), - output_ctrl = $layout/RSplit/CResults/Tabs/OutputText, - run_button = $layout/ControlBar/RunAll, - shortcuts_button = $layout/ControlBar/Shortcuts, - - settings_button = $layout/ControlBar/Settings, - run_results_button = $layout/ControlBar/RunResultsBtn, - output_button = $layout/ControlBar/OutputBtn, - - settings = $layout/RSplit/sc/Settings, - shortcut_dialog = $BottomPanelShortcuts, - light = $layout/RSplit/CResults/ControlBar/Light, - results = { - bar = $layout/RSplit/CResults/ControlBar, - passing = $layout/RSplit/CResults/ControlBar/Passing/value, - failing = $layout/RSplit/CResults/ControlBar/Failing/value, - pending = $layout/RSplit/CResults/ControlBar/Pending/value, - errors = $layout/RSplit/CResults/ControlBar/Errors/value, - warnings = $layout/RSplit/CResults/ControlBar/Warnings/value, - orphans = $layout/RSplit/CResults/ControlBar/Orphans/value - }, - run_at_cursor = $layout/ControlBar/RunAtCursor, - run_results = $layout/RSplit/CResults/Tabs/RunResults -} - - -func _init(): - _gut_config.load_panel_options(RUNNER_JSON_PATH) - - -func _ready(): - _ctrls.results.bar.connect('draw', self, '_on_results_bar_draw', [_ctrls.results.bar]) - hide_settings(!_ctrls.settings_button.pressed) - _gut_config_gui = GutConfigGui.new(_ctrls.settings) - _gut_config_gui.set_options(_gut_config.options) - - _apply_options_to_controls() - - _ctrls.shortcuts_button.icon = get_icon('ShortCut', 'EditorIcons') - _ctrls.settings_button.icon = get_icon('Tools', 'EditorIcons') - _ctrls.run_results_button.icon = get_icon('AnimationTrackGroup', 'EditorIcons') # Tree - _ctrls.output_button.icon = get_icon('Font', 'EditorIcons') - - _ctrls.run_results.set_output_control(_ctrls.output_ctrl) - _ctrls.run_results.set_font( - _gut_config.options.panel_options.font_name, - _gut_config.options.panel_options.font_size) - - var check_import = load('res://addons/gut/images/red.png') - if(check_import == null): - _ctrls.run_results.add_centered_text("GUT got some new images that are not imported yet. Please restart Godot.") - print('GUT got some new images that are not imported yet. Please restart Godot.') - else: - _ctrls.run_results.add_centered_text("Let's run some tests!") - - -func _apply_options_to_controls(): - hide_settings(_gut_config.options.panel_options.hide_settings) - hide_result_tree(_gut_config.options.panel_options.hide_result_tree) - hide_output_text(_gut_config.options.panel_options.hide_output_text) - - _ctrls.output_ctrl.set_use_colors(_gut_config.options.panel_options.use_colors) - _ctrls.output_ctrl.set_all_fonts(_gut_config.options.panel_options.font_name) - _ctrls.output_ctrl.set_font_size(_gut_config.options.panel_options.font_size) - - _ctrls.run_results.set_font( - _gut_config.options.panel_options.font_name, - _gut_config.options.panel_options.font_size) - _ctrls.run_results.set_show_orphans(!_gut_config.options.hide_orphans) - - -func _process(delta): - if(_is_running): - if(!_interface.is_playing_scene()): - _is_running = false - _ctrls.output_ctrl.add_text("\ndone") - load_result_output() - _gut_plugin.make_bottom_panel_item_visible(self) - -# --------------- -# Private -# --------------- - -func load_shortcuts(): - _ctrls.shortcut_dialog.load_shortcuts(SHORTCUTS_PATH) - _apply_shortcuts() - - -func _is_test_script(script): - var from = script.get_base_script() - while(from and from.resource_path != 'res://addons/gut/test.gd'): - from = from.get_base_script() - - return from != null - - -func _show_errors(errs): - _ctrls.output_ctrl.clear() - var text = "Cannot run tests, you have a configuration error:\n" - for e in errs: - text += str('* ', e, "\n") - text += "Check your settings ----->" - _ctrls.output_ctrl.add_text(text) - hide_output_text(false) - hide_settings(false) - - -func _save_config(): - _gut_config.options = _gut_config_gui.get_options(_gut_config.options) - _gut_config.options.panel_options.hide_settings = !_ctrls.settings_button.pressed - _gut_config.options.panel_options.hide_result_tree = !_ctrls.run_results_button.pressed - _gut_config.options.panel_options.hide_output_text = !_ctrls.output_button.pressed - _gut_config.options.panel_options.use_colors = _ctrls.output_ctrl.get_use_colors() - - var w_result = _gut_config.write_options(RUNNER_JSON_PATH) - if(w_result != OK): - push_error(str('Could not write options to ', RUNNER_JSON_PATH, ': ', w_result)) - return; - - -func _run_tests(): - var issues = _gut_config_gui.get_config_issues() - if(issues.size() > 0): - _show_errors(issues) - return - - write_file(RESULT_FILE, 'Run in progress') - _save_config() - _apply_options_to_controls() - - _ctrls.output_ctrl.clear() - _ctrls.run_results.clear() - _ctrls.run_results.add_centered_text('Running...') - - _interface.play_custom_scene('res://addons/gut/gui/GutRunner.tscn') - _is_running = true - _ctrls.output_ctrl.add_text('Running...') - - -func _apply_shortcuts(): - _ctrls.run_button.shortcut = _ctrls.shortcut_dialog.get_run_all() - - _ctrls.run_at_cursor.get_script_button().shortcut = \ - _ctrls.shortcut_dialog.get_run_current_script() - _ctrls.run_at_cursor.get_inner_button().shortcut = \ - _ctrls.shortcut_dialog.get_run_current_inner() - _ctrls.run_at_cursor.get_test_button().shortcut = \ - _ctrls.shortcut_dialog.get_run_current_test() - - _panel_button.shortcut = _ctrls.shortcut_dialog.get_panel_button() - - -func _run_all(): - _gut_config.options.selected = null - _gut_config.options.inner_class = null - _gut_config.options.unit_test_name = null - - _run_tests() - - -# --------------- -# Events -# --------------- -func _on_results_bar_draw(bar): - bar.draw_rect(Rect2(Vector2(0, 0), bar.rect_size), Color(0, 0, 0, .2)) - - -func _on_Light_draw(): - var l = _ctrls.light - l.draw_circle(Vector2(l.rect_size.x / 2, l.rect_size.y / 2), l.rect_size.x / 2, _light_color) - - -func _on_editor_script_changed(script): - if(script): - set_current_script(script) - - -func _on_RunAll_pressed(): - _run_all() - - -func _on_Shortcuts_pressed(): - _ctrls.shortcut_dialog.popup_centered() - - -func _on_BottomPanelShortcuts_popup_hide(): - _apply_shortcuts() - _ctrls.shortcut_dialog.save_shortcuts(SHORTCUTS_PATH) - - -func _on_RunAtCursor_run_tests(what): - _gut_config.options.selected = what.script - _gut_config.options.inner_class = what.inner_class - _gut_config.options.unit_test_name = what.test_method - - _run_tests() - - -func _on_Settings_pressed(): - hide_settings(!_ctrls.settings_button.pressed) - _save_config() - - -func _on_OutputBtn_pressed(): - hide_output_text(!_ctrls.output_button.pressed) - _save_config() - - -func _on_RunResultsBtn_pressed(): - hide_result_tree(! _ctrls.run_results_button.pressed) - _save_config() - - -# Currently not used, but will be when I figure out how to put -# colors into the text results -func _on_UseColors_pressed(): - pass - -# --------------- -# Public -# --------------- -func hide_result_tree(should): - _ctrls.run_results.visible = !should - _ctrls.run_results_button.pressed = !should - - -func hide_settings(should): - var s_scroll = _ctrls.settings.get_parent() - s_scroll.visible = !should - - # collapse only collapses the first control, so we move - # settings around to be the collapsed one - if(should): - s_scroll.get_parent().move_child(s_scroll, 0) - else: - s_scroll.get_parent().move_child(s_scroll, 1) - - $layout/RSplit.collapsed = should - _ctrls.settings_button.pressed = !should - - -func hide_output_text(should): - $layout/RSplit/CResults/Tabs/OutputText.visible = !should - _ctrls.output_button.pressed = !should - - -func load_result_output(): - _ctrls.output_ctrl.load_file(RESULT_FILE) - - var summary = get_file_as_text(RESULT_JSON) - var results = JSON.parse(summary) - if(results.error != OK): - return - - _ctrls.run_results.load_json_results(results.result) - - var summary_json = results.result['test_scripts']['props'] - _ctrls.results.passing.text = str(summary_json.passing) - _ctrls.results.passing.get_parent().visible = true - - _ctrls.results.failing.text = str(summary_json.failures) - _ctrls.results.failing.get_parent().visible = true - - _ctrls.results.pending.text = str(summary_json.pending) - _ctrls.results.pending.get_parent().visible = _ctrls.results.pending.text != '0' - - _ctrls.results.errors.text = str(summary_json.errors) - _ctrls.results.errors.get_parent().visible = _ctrls.results.errors.text != '0' - - _ctrls.results.warnings.text = str(summary_json.warnings) - _ctrls.results.warnings.get_parent().visible = _ctrls.results.warnings.text != '0' - - _ctrls.results.orphans.text = str(summary_json.orphans) - _ctrls.results.orphans.get_parent().visible = _ctrls.results.orphans.text != '0' and !_gut_config.options.hide_orphans - - if(summary_json.tests == 0): - _light_color = Color(1, 0, 0, .75) - elif(summary_json.failures != 0): - _light_color = Color(1, 0, 0, .75) - elif(summary_json.pending != 0): - _light_color = Color(1, 1, 0, .75) - else: - _light_color = Color(0, 1, 0, .75) - _ctrls.light.visible = true - _ctrls.light.update() - - -func set_current_script(script): - if(script): - if(_is_test_script(script)): - var file = script.resource_path.get_file() - _last_selected_path = script.resource_path.get_file() - _ctrls.run_at_cursor.activate_for_script(script.resource_path) - - -func set_interface(value): - _interface = value - _interface.get_script_editor().connect("editor_script_changed", self, '_on_editor_script_changed') - - var ste = ScriptTextEditors.new(_interface.get_script_editor()) - _ctrls.run_results.set_interface(_interface) - _ctrls.run_results.set_script_text_editors(ste) - _ctrls.run_at_cursor.set_script_text_editors(ste) - set_current_script(_interface.get_script_editor().get_current_script()) - - -func set_plugin(value): - _gut_plugin = value - - -func set_panel_button(value): - _panel_button = value - -# ------------------------------------------------------------------------------ -# Write a file. -# ------------------------------------------------------------------------------ -func write_file(path, content): - var f = File.new() - var result = f.open(path, f.WRITE) - if(result == OK): - f.store_string(content) - f.close() - return result - - -# ------------------------------------------------------------------------------ -# Returns the text of a file or an empty string if the file could not be opened. -# ------------------------------------------------------------------------------ -func get_file_as_text(path): - var to_return = '' - var f = File.new() - var result = f.open(path, f.READ) - if(result == OK): - to_return = f.get_as_text() - f.close() - return to_return - - -# ------------------------------------------------------------------------------ -# return if_null if value is null otherwise return value -# ------------------------------------------------------------------------------ -func nvl(value, if_null): - if(value == null): - return if_null - else: - return value - diff --git a/addons/gut/gui/GutBottomPanel.tscn b/addons/gut/gui/GutBottomPanel.tscn deleted file mode 100644 index 7ec6649..0000000 --- a/addons/gut/gui/GutBottomPanel.tscn +++ /dev/null @@ -1,385 +0,0 @@ -[gd_scene load_steps=11 format=2] - -[ext_resource path="res://addons/gut/gui/GutBottomPanel.gd" type="Script" id=1] -[ext_resource path="res://addons/gut/gui/BottomPanelShortcuts.tscn" type="PackedScene" id=2] -[ext_resource path="res://addons/gut/gui/RunAtCursor.tscn" type="PackedScene" id=3] -[ext_resource path="res://addons/gut/gui/play.png" type="Texture" id=4] -[ext_resource path="res://addons/gut/gui/RunResults.tscn" type="PackedScene" id=5] -[ext_resource path="res://addons/gut/gui/OutputText.tscn" type="PackedScene" id=6] - -[sub_resource type="InputEventKey" id=8] -control = true -scancode = 49 - -[sub_resource type="ShortCut" id=9] -shortcut = SubResource( 8 ) - -[sub_resource type="Image" id=10] -data = { -"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), -"format": "LumAlpha8", -"height": 16, -"mipmaps": false, -"width": 16 -} - -[sub_resource type="ImageTexture" id=2] -flags = 4 -flags = 4 -image = SubResource( 10 ) -size = Vector2( 16, 16 ) - -[node name="GutBottomPanel" type="Control"] -anchor_left = -0.0025866 -anchor_top = -0.00176575 -anchor_right = 0.997413 -anchor_bottom = 0.998234 -margin_left = 2.64868 -margin_top = 1.05945 -margin_right = 2.64862 -margin_bottom = 1.05945 -rect_min_size = Vector2( 0, 300 ) -script = ExtResource( 1 ) - -[node name="layout" type="VBoxContainer" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="ControlBar" type="HBoxContainer" parent="layout"] -margin_right = 1023.0 -margin_bottom = 40.0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="RunAll" type="Button" parent="layout/ControlBar"] -margin_right = 150.0 -margin_bottom = 40.0 -rect_min_size = Vector2( 150, 0 ) -hint_tooltip = "Run all test scripts in the suite." -size_flags_vertical = 11 -shortcut = SubResource( 9 ) -text = "Run All" -icon = ExtResource( 4 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Label" type="Label" parent="layout/ControlBar"] -margin_left = 154.0 -margin_top = 13.0 -margin_right = 213.0 -margin_bottom = 27.0 -hint_tooltip = "When a test script is edited, buttons are displayed to -run the opened script or an Inner-Test-Class or a -single test. The buttons change based on the location -of the cursor in the file. - -These buttons will remain active when editing other -items so that you can run tests without having to switch -back to the test script. - -You can assign keyboard shortcuts for these buttons -using the \"shortcuts\" button in the GUT panel." -mouse_filter = 1 -text = "Current: " - -[node name="RunAtCursor" parent="layout/ControlBar" instance=ExtResource( 3 )] -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 217.0 -margin_right = 548.0 -margin_bottom = 40.0 -rect_min_size = Vector2( 0, 40 ) - -[node name="CenterContainer2" type="CenterContainer" parent="layout/ControlBar"] -margin_left = 552.0 -margin_right = 883.0 -margin_bottom = 40.0 -size_flags_horizontal = 3 - -[node name="Sep1" type="ColorRect" parent="layout/ControlBar"] -margin_left = 887.0 -margin_right = 889.0 -margin_bottom = 40.0 -rect_min_size = Vector2( 2, 0 ) - -[node name="RunResultsBtn" type="ToolButton" parent="layout/ControlBar"] -margin_left = 893.0 -margin_right = 921.0 -margin_bottom = 40.0 -hint_tooltip = "Show/Hide Results Tree Panel." -toggle_mode = true -pressed = true -icon = SubResource( 2 ) - -[node name="OutputBtn" type="ToolButton" parent="layout/ControlBar"] -margin_left = 925.0 -margin_right = 953.0 -margin_bottom = 40.0 -hint_tooltip = "Show/Hide Output Panel." -toggle_mode = true -pressed = true -icon = SubResource( 2 ) - -[node name="Settings" type="ToolButton" parent="layout/ControlBar"] -margin_left = 957.0 -margin_right = 985.0 -margin_bottom = 40.0 -hint_tooltip = "Show/Hide Settings Panel." -toggle_mode = true -icon = SubResource( 2 ) - -[node name="Sep2" type="ColorRect" parent="layout/ControlBar"] -margin_left = 989.0 -margin_right = 991.0 -margin_bottom = 40.0 -rect_min_size = Vector2( 2, 0 ) - -[node name="Shortcuts" type="ToolButton" parent="layout/ControlBar"] -margin_left = 995.0 -margin_right = 1023.0 -margin_bottom = 40.0 -hint_tooltip = "Set shortcuts for GUT buttons. Shortcuts do not work when the GUT panel is not visible." -size_flags_vertical = 11 -icon = SubResource( 2 ) - -[node name="RSplit" type="HSplitContainer" parent="layout"] -margin_top = 44.0 -margin_right = 1023.0 -margin_bottom = 599.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -collapsed = true - -[node name="sc" type="ScrollContainer" parent="layout/RSplit"] -visible = false -margin_left = 593.0 -margin_right = 1093.0 -margin_bottom = 555.0 -rect_min_size = Vector2( 500, 0 ) -mouse_filter = 1 -size_flags_vertical = 3 - -[node name="Settings" type="VBoxContainer" parent="layout/RSplit/sc"] -margin_right = 500.0 -margin_bottom = 908.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="CResults" type="VBoxContainer" parent="layout/RSplit"] -margin_right = 1023.0 -margin_bottom = 555.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="ControlBar" type="HBoxContainer" parent="layout/RSplit/CResults"] -margin_right = 1023.0 -margin_bottom = 35.0 -rect_min_size = Vector2( 0, 35 ) - -[node name="Light" type="Control" parent="layout/RSplit/CResults/ControlBar"] -visible = false -margin_right = 30.0 -margin_bottom = 35.0 -rect_min_size = Vector2( 30, 30 ) - -[node name="Passing" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] -visible = false -margin_left = 34.0 -margin_right = 107.0 -margin_bottom = 35.0 - -[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Passing"] -margin_right = 2.0 -margin_bottom = 35.0 -rect_min_size = Vector2( 2, 0 ) - -[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Passing"] -margin_left = 6.0 -margin_top = 10.0 -margin_right = 54.0 -margin_bottom = 24.0 -text = "Passing" - -[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Passing"] -margin_left = 58.0 -margin_top = 10.0 -margin_right = 73.0 -margin_bottom = 24.0 -text = "---" - -[node name="Failing" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] -visible = false -margin_left = 34.0 -margin_right = 100.0 -margin_bottom = 35.0 - -[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Failing"] -margin_right = 2.0 -margin_bottom = 35.0 -rect_min_size = Vector2( 2, 0 ) - -[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Failing"] -margin_left = 6.0 -margin_top = 10.0 -margin_right = 47.0 -margin_bottom = 24.0 -text = "Failing" - -[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Failing"] -margin_left = 51.0 -margin_top = 10.0 -margin_right = 66.0 -margin_bottom = 24.0 -text = "---" - -[node name="Pending" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] -visible = false -margin_left = 34.0 -margin_right = 110.0 -margin_bottom = 35.0 - -[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Pending"] -margin_right = 2.0 -margin_bottom = 35.0 -rect_min_size = Vector2( 2, 0 ) - -[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Pending"] -margin_left = 6.0 -margin_top = 10.0 -margin_right = 57.0 -margin_bottom = 24.0 -text = "Pending" - -[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Pending"] -margin_left = 61.0 -margin_top = 10.0 -margin_right = 76.0 -margin_bottom = 24.0 -text = "---" - -[node name="Orphans" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] -visible = false -margin_left = 34.0 -margin_right = 110.0 -margin_bottom = 35.0 - -[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Orphans"] -margin_right = 2.0 -margin_bottom = 35.0 -rect_min_size = Vector2( 2, 0 ) - -[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Orphans"] -margin_left = 6.0 -margin_top = 10.0 -margin_right = 57.0 -margin_bottom = 24.0 -text = "Orphans" - -[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Orphans"] -margin_left = 61.0 -margin_top = 10.0 -margin_right = 76.0 -margin_bottom = 24.0 -text = "---" - -[node name="Errors" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] -visible = false -margin_left = 34.0 -margin_right = 96.0 -margin_bottom = 35.0 - -[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Errors"] -margin_right = 2.0 -margin_bottom = 35.0 -rect_min_size = Vector2( 2, 0 ) - -[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Errors"] -margin_left = 6.0 -margin_top = 10.0 -margin_right = 43.0 -margin_bottom = 24.0 -hint_tooltip = "The number of GUT errors generated. This does not include engine errors." -text = "Errors" - -[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Errors"] -margin_left = 47.0 -margin_top = 10.0 -margin_right = 62.0 -margin_bottom = 24.0 -text = "---" - -[node name="Warnings" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] -visible = false -margin_left = 34.0 -margin_right = 118.0 -margin_bottom = 35.0 - -[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Warnings"] -margin_right = 2.0 -margin_bottom = 35.0 -rect_min_size = Vector2( 2, 0 ) - -[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Warnings"] -margin_left = 6.0 -margin_top = 10.0 -margin_right = 65.0 -margin_bottom = 24.0 -text = "Warnings" -__meta__ = { -"_editor_description_": "The number of GUT Warnings generated. This does not include engine warnings." -} - -[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Warnings"] -margin_left = 69.0 -margin_top = 10.0 -margin_right = 84.0 -margin_bottom = 24.0 -text = "---" - -[node name="CenterContainer" type="CenterContainer" parent="layout/RSplit/CResults/ControlBar"] -margin_right = 1023.0 -margin_bottom = 35.0 -size_flags_horizontal = 3 - -[node name="Tabs" type="HSplitContainer" parent="layout/RSplit/CResults"] -margin_top = 39.0 -margin_right = 1023.0 -margin_bottom = 555.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="RunResults" parent="layout/RSplit/CResults/Tabs" instance=ExtResource( 5 )] -margin_right = 505.0 -margin_bottom = 516.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="OutputText" parent="layout/RSplit/CResults/Tabs" instance=ExtResource( 6 )] -margin_left = 517.0 -margin_right = 1023.0 -margin_bottom = 516.0 - -[node name="BottomPanelShortcuts" parent="." instance=ExtResource( 2 )] -visible = false -anchor_left = -0.000517324 -anchor_top = 0.000882874 -anchor_right = 0.233483 -anchor_bottom = 0.328883 -margin_left = 10.0649 -margin_top = -173.752 -margin_right = 31.6969 -margin_bottom = -125.552 - -[connection signal="pressed" from="layout/ControlBar/RunAll" to="." method="_on_RunAll_pressed"] -[connection signal="run_tests" from="layout/ControlBar/RunAtCursor" to="." method="_on_RunAtCursor_run_tests"] -[connection signal="pressed" from="layout/ControlBar/RunResultsBtn" to="." method="_on_RunResultsBtn_pressed"] -[connection signal="pressed" from="layout/ControlBar/OutputBtn" to="." method="_on_OutputBtn_pressed"] -[connection signal="pressed" from="layout/ControlBar/Settings" to="." method="_on_Settings_pressed"] -[connection signal="pressed" from="layout/ControlBar/Shortcuts" to="." method="_on_Shortcuts_pressed"] -[connection signal="draw" from="layout/RSplit/CResults/ControlBar/Light" to="." method="_on_Light_draw"] -[connection signal="popup_hide" from="BottomPanelShortcuts" to="." method="_on_BottomPanelShortcuts_popup_hide"] diff --git a/addons/gut/gui/GutRunner.gd b/addons/gut/gui/GutRunner.gd deleted file mode 100644 index 608fc26..0000000 --- a/addons/gut/gui/GutRunner.gd +++ /dev/null @@ -1,95 +0,0 @@ -extends Node2D - -var Gut = load('res://addons/gut/gut.gd') -var ResultExporter = load('res://addons/gut/result_exporter.gd') -var GutConfig = load('res://addons/gut/gut_config.gd') - -const RUNNER_JSON_PATH = 'res://.gut_editor_config.json' -const RESULT_FILE = 'user://.gut_editor.bbcode' -const RESULT_JSON = 'user://.gut_editor.json' - -var _gut_config = null -var _gut = null; -var _wrote_results = false -# Flag for when this is being used at the command line. Otherwise it is -# assumed this is being used by the panel and being launched with -# play_custom_scene -var _cmdln_mode = false - -onready var _gut_layer = $GutLayer - - -func _ready(): - if(_gut_config == null): - _gut_config = GutConfig.new() - _gut_config.load_panel_options(RUNNER_JSON_PATH) - - # The command line will call run_tests on its own. When used from the panel - # we have to kick off the tests ourselves b/c there's no way I know of to - # interact with the scene that was run via play_custom_scene. - if(!_cmdln_mode): - call_deferred('run_tests') - - -func run_tests(): - if(_gut == null): - _gut = Gut.new() - - _gut.set_add_children_to(self) - if(_gut_config.options.gut_on_top): - _gut_layer.add_child(_gut) - else: - add_child(_gut) - - if(!_cmdln_mode): - _gut.connect('tests_finished', self, '_on_tests_finished', - [_gut_config.options.should_exit, _gut_config.options.should_exit_on_success]) - - _gut_config.config_gut(_gut) - if(_gut_config.options.gut_on_top): - _gut.get_gui().goto_bottom_right_corner() - - var run_rest_of_scripts = _gut_config.options.unit_test_name == '' - _gut.test_scripts(run_rest_of_scripts) - - -func _write_results(): - var content = _gut.get_logger().get_gui_bbcode() - - var f = File.new() - var result = f.open(RESULT_FILE, f.WRITE) - if(result == OK): - f.store_string(content) - f.close() - else: - print('ERROR Could not save bbcode, result = ', result) - - var exporter = ResultExporter.new() - var f_result = exporter.write_json_file(_gut, RESULT_JSON) - _wrote_results = true - - -func _exit_tree(): - if(!_wrote_results and !_cmdln_mode): - _write_results() - - -func _on_tests_finished(should_exit, should_exit_on_success): - _write_results() - - if(should_exit): - get_tree().quit() - elif(should_exit_on_success and _gut.get_fail_count() == 0): - get_tree().quit() - - -func get_gut(): - if(_gut == null): - _gut = Gut.new() - return _gut - -func set_gut_config(which): - _gut_config = which - -func set_cmdln_mode(is_it): - _cmdln_mode = is_it diff --git a/addons/gut/gui/GutRunner.tscn b/addons/gut/gui/GutRunner.tscn deleted file mode 100644 index 077e411..0000000 --- a/addons/gut/gui/GutRunner.tscn +++ /dev/null @@ -1,9 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://addons/gut/gui/GutRunner.gd" type="Script" id=1] - -[node name="GutRunner" type="Node2D"] -script = ExtResource( 1 ) - -[node name="GutLayer" type="CanvasLayer" parent="."] -layer = 128 diff --git a/addons/gut/gui/GutSceneTheme.tres b/addons/gut/gui/GutSceneTheme.tres deleted file mode 100644 index 565a6af..0000000 --- a/addons/gut/gui/GutSceneTheme.tres +++ /dev/null @@ -1,11 +0,0 @@ -[gd_resource type="Theme" load_steps=3 format=2] - -[sub_resource type="DynamicFontData" id=9] -font_path = "res://addons/gut/fonts/AnonymousPro-Regular.ttf" - -[sub_resource type="DynamicFont" id=10] -size = 14 -font_data = SubResource( 9 ) - -[resource] -default_font = SubResource( 10 ) diff --git a/addons/gut/gui/OutputText.gd b/addons/gut/gui/OutputText.gd deleted file mode 100644 index e5cf2b6..0000000 --- a/addons/gut/gui/OutputText.gd +++ /dev/null @@ -1,291 +0,0 @@ -extends VBoxContainer -tool - -class SearchResults: - const L = TextEdit.SEARCH_RESULT_LINE - const C = TextEdit.SEARCH_RESULT_COLUMN - - var positions = [] - var te = null - var _last_term = '' - - func _search_te(text, start_position, flags=0): - var start_pos = start_position - if(start_pos[L] < 0 or start_pos[L] > te.get_line_count()): - start_pos[L] = 0 - if(start_pos[C] < 0): - start_pos[L] = 0 - - var result = te.search(text, flags, start_pos[L], start_pos[C]) - if(result.size() == 2 and result[L] == start_position[L] and - result[C] == start_position[C] and text == _last_term): - if(flags == TextEdit.SEARCH_BACKWARDS): - result[C] -= 1 - else: - result[C] += 1 - result = _search_te(text, result, flags) - elif(result.size() == 2): - te.scroll_vertical = result[L] - te.select(result[L], result[C], result[L], result[C] + text.length()) - te.cursor_set_column(result[C]) - te.cursor_set_line(result[L]) - te.center_viewport_to_cursor() - - _last_term = text - te.center_viewport_to_cursor() - return result - - func _cursor_to_pos(): - var to_return = [0, 0] - to_return[L] = te.cursor_get_line() - to_return[C] = te.cursor_get_column() - return to_return - - func find_next(term): - return _search_te(term, _cursor_to_pos()) - - func find_prev(term): - var new_pos = _search_te(term, _cursor_to_pos(), TextEdit.SEARCH_BACKWARDS) - return new_pos - - func get_next_pos(): - pass - - func get_prev_pos(): - pass - - func clear(): - pass - - func find_all(text): - var c_pos = [0, 0] - var found = true - var last_pos = [0, 0] - positions.clear() - - while(found): - c_pos = te.search(text, 0, c_pos[L], c_pos[C]) - - if(c_pos.size() > 0 and - (c_pos[L] > last_pos[L] or - (c_pos[L] == last_pos[L] and c_pos[C] > last_pos[C]))): - positions.append([c_pos[L], c_pos[C]]) - c_pos[C] += 1 - last_pos = c_pos - else: - found = false - - - -onready var _ctrls = { - output = $Output, - - copy_button = $Toolbar/CopyButton, - use_colors = $Toolbar/UseColors, - clear_button = $Toolbar/ClearButton, - word_wrap = $Toolbar/WordWrap, - show_search = $Toolbar/ShowSearch, - - search_bar = { - bar = $Search, - search_term = $Search/SearchTerm, - } -} -var _sr = SearchResults.new() - -func _test_running_setup(): - _ctrls.use_colors.text = 'use colors' - _ctrls.show_search.text = 'search' - _ctrls.word_wrap.text = 'ww' - - set_all_fonts("CourierPrime") - set_font_size(20) - - load_file('user://.gut_editor.bbcode') - - -func _ready(): - _sr.te = _ctrls.output - _ctrls.use_colors.icon = get_icon('RichTextEffect', 'EditorIcons') - _ctrls.show_search.icon = get_icon('Search', 'EditorIcons') - _ctrls.word_wrap.icon = get_icon('Loop', 'EditorIcons') - - _setup_colors() - if(get_parent() == get_tree().root): - _test_running_setup() - - -# ------------------ -# Private -# ------------------ -func _setup_colors(): - _ctrls.output.clear_colors() - var keywords = [ - ['Failed', Color.red], - ['Passed', Color.green], - ['Pending', Color.yellow], - ['Orphans', Color.yellow], - ['WARNING', Color.yellow], - ['ERROR', Color.red] - ] - - for keyword in keywords: - _ctrls.output.add_keyword_color(keyword[0], keyword[1]) - - var f_color = _ctrls.output.get_color("font_color") - _ctrls.output.add_color_override("font_color_readonly", f_color) - _ctrls.output.add_color_override("function_color", f_color) - _ctrls.output.add_color_override("member_variable_color", f_color) - _ctrls.output.update() - - -func _set_font(font_name, custom_name): - var rtl = _ctrls.output - if(font_name == null): - rtl.set('custom_fonts/' + custom_name, null) - else: - var dyn_font = DynamicFont.new() - var font_data = DynamicFontData.new() - font_data.font_path = 'res://addons/gut/fonts/' + font_name + '.ttf' - font_data.antialiased = true - dyn_font.font_data = font_data - rtl.set('custom_fonts/' + custom_name, dyn_font) - - -# ------------------ -# Events -# ------------------ -func _on_CopyButton_pressed(): - copy_to_clipboard() - - -func _on_UseColors_pressed(): - _ctrls.output.syntax_highlighting = _ctrls.use_colors.pressed - - -func _on_ClearButton_pressed(): - clear() - - -func _on_ShowSearch_pressed(): - show_search(_ctrls.show_search.pressed) - - -func _on_SearchTerm_focus_entered(): - _ctrls.search_bar.search_term.call_deferred('select_all') - -func _on_SearchNext_pressed(): - _sr.find_next(_ctrls.search_bar.search_term.text) - - -func _on_SearchPrev_pressed(): - _sr.find_prev(_ctrls.search_bar.search_term.text) - - -func _on_SearchTerm_text_changed(new_text): - if(new_text == ''): - _ctrls.output.deselect() - else: - _sr.find_next(new_text) - - -func _on_SearchTerm_text_entered(new_text): - if(Input.is_physical_key_pressed(KEY_SHIFT)): - _sr.find_prev(new_text) - else: - _sr.find_next(new_text) - - -func _on_SearchTerm_gui_input(event): - if(event is InputEventKey and !event.pressed and event.scancode == KEY_ESCAPE): - show_search(false) - -func _on_WordWrap_pressed(): - _ctrls.output.wrap_enabled = _ctrls.word_wrap.pressed - _ctrls.output.update() - -# ------------------ -# Public -# ------------------ -func show_search(should): - _ctrls.search_bar.bar.visible = should - if(should): - _ctrls.search_bar.search_term.grab_focus() - _ctrls.search_bar.search_term.select_all() - _ctrls.show_search.pressed = should - - -func search(text, start_pos, highlight=true): - return _sr.find_next(text) - - -func copy_to_clipboard(): - var selected = _ctrls.output.get_selection_text() - if(selected != ''): - OS.clipboard = selected - else: - OS.clipboard = _ctrls.output.text - - -func clear(): - _ctrls.output.text = '' - - -func set_all_fonts(base_name): - if(base_name == 'Default'): - _set_font(null, 'font') -# _set_font(null, 'normal_font') -# _set_font(null, 'bold_font') -# _set_font(null, 'italics_font') -# _set_font(null, 'bold_italics_font') - else: - _set_font(base_name + '-Regular', 'font') -# _set_font(base_name + '-Regular', 'normal_font') -# _set_font(base_name + '-Bold', 'bold_font') -# _set_font(base_name + '-Italic', 'italics_font') -# _set_font(base_name + '-BoldItalic', 'bold_italics_font') - - -func set_font_size(new_size): - var rtl = _ctrls.output - if(rtl.get('custom_fonts/font') != null): - rtl.get('custom_fonts/font').size = new_size -# rtl.get('custom_fonts/bold_italics_font').size = new_size -# rtl.get('custom_fonts/bold_font').size = new_size -# rtl.get('custom_fonts/italics_font').size = new_size -# rtl.get('custom_fonts/normal_font').size = new_size - - -func set_use_colors(value): - pass - - -func get_use_colors(): - return false; - - -func get_rich_text_edit(): - return _ctrls.output - - -func load_file(path): - var f = File.new() - var result = f.open(path, f.READ) - if(result != OK): - return - - var t = f.get_as_text() - f.close() - _ctrls.output.text = t - _ctrls.output.scroll_vertical = _ctrls.output.get_line_count() - _ctrls.output.set_deferred('scroll_vertical', _ctrls.output.get_line_count()) - - -func add_text(text): - if(is_inside_tree()): - _ctrls.output.text += text - - -func scroll_to_line(line): - _ctrls.output.scroll_vertical = line - _ctrls.output.cursor_set_line(line) diff --git a/addons/gut/gui/OutputText.tscn b/addons/gut/gui/OutputText.tscn deleted file mode 100644 index d7c693a..0000000 --- a/addons/gut/gui/OutputText.tscn +++ /dev/null @@ -1,123 +0,0 @@ -[gd_scene load_steps=4 format=2] - -[ext_resource path="res://addons/gut/gui/OutputText.gd" type="Script" id=1] - -[sub_resource type="Image" id=3] -data = { -"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), -"format": "LumAlpha8", -"height": 16, -"mipmaps": false, -"width": 16 -} - -[sub_resource type="ImageTexture" id=2] -flags = 4 -flags = 4 -image = SubResource( 3 ) -size = Vector2( 16, 16 ) - -[node name="OutputText" type="VBoxContainer"] -margin_right = 862.0 -margin_bottom = 523.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -script = ExtResource( 1 ) - -[node name="Toolbar" type="HBoxContainer" parent="."] -margin_right = 862.0 -margin_bottom = 24.0 -size_flags_horizontal = 3 - -[node name="ShowSearch" type="ToolButton" parent="Toolbar"] -margin_right = 28.0 -margin_bottom = 24.0 -toggle_mode = true -icon = SubResource( 2 ) - -[node name="UseColors" type="ToolButton" parent="Toolbar"] -margin_left = 32.0 -margin_right = 60.0 -margin_bottom = 24.0 -hint_tooltip = "Colorize output. - It's not the same as everywhere else (long story), - but it is better than nothing." -toggle_mode = true -pressed = true -icon = SubResource( 2 ) - -[node name="WordWrap" type="ToolButton" parent="Toolbar"] -margin_left = 64.0 -margin_right = 92.0 -margin_bottom = 24.0 -hint_tooltip = "Word wrap" -toggle_mode = true -icon = SubResource( 2 ) - -[node name="CenterContainer" type="CenterContainer" parent="Toolbar"] -margin_left = 96.0 -margin_right = 743.0 -margin_bottom = 24.0 -size_flags_horizontal = 3 - -[node name="CopyButton" type="Button" parent="Toolbar"] -margin_left = 747.0 -margin_right = 798.0 -margin_bottom = 24.0 -hint_tooltip = "Copy to clipboard" -text = " Copy " - -[node name="ClearButton" type="Button" parent="Toolbar"] -margin_left = 802.0 -margin_right = 862.0 -margin_bottom = 24.0 -text = " Clear " - -[node name="Output" type="TextEdit" parent="."] -margin_top = 28.0 -margin_right = 862.0 -margin_bottom = 523.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -readonly = true -highlight_current_line = true -syntax_highlighting = true -show_line_numbers = true -smooth_scrolling = true - -[node name="Search" type="HBoxContainer" parent="."] -visible = false -margin_top = 499.0 -margin_right = 862.0 -margin_bottom = 523.0 - -[node name="SearchTerm" type="LineEdit" parent="Search"] -margin_right = 804.0 -margin_bottom = 24.0 -size_flags_horizontal = 3 - -[node name="SearchNext" type="Button" parent="Search"] -margin_left = 808.0 -margin_right = 862.0 -margin_bottom = 24.0 -hint_tooltip = "Find next (enter)" -text = "Next" - -[node name="SearchPrev" type="Button" parent="Search"] -margin_left = 808.0 -margin_right = 820.0 -margin_bottom = 20.0 -hint_tooltip = "Find previous (shift + enter)" -text = "Prev" - -[connection signal="pressed" from="Toolbar/ShowSearch" to="." method="_on_ShowSearch_pressed"] -[connection signal="pressed" from="Toolbar/UseColors" to="." method="_on_UseColors_pressed"] -[connection signal="pressed" from="Toolbar/WordWrap" to="." method="_on_WordWrap_pressed"] -[connection signal="pressed" from="Toolbar/CopyButton" to="." method="_on_CopyButton_pressed"] -[connection signal="pressed" from="Toolbar/ClearButton" to="." method="_on_ClearButton_pressed"] -[connection signal="focus_entered" from="Search/SearchTerm" to="." method="_on_SearchTerm_focus_entered"] -[connection signal="gui_input" from="Search/SearchTerm" to="." method="_on_SearchTerm_gui_input"] -[connection signal="text_changed" from="Search/SearchTerm" to="." method="_on_SearchTerm_text_changed"] -[connection signal="text_entered" from="Search/SearchTerm" to="." method="_on_SearchTerm_text_entered"] -[connection signal="pressed" from="Search/SearchNext" to="." method="_on_SearchNext_pressed"] -[connection signal="pressed" from="Search/SearchPrev" to="." method="_on_SearchPrev_pressed"] diff --git a/addons/gut/gui/RunAtCursor.gd b/addons/gut/gui/RunAtCursor.gd deleted file mode 100644 index dc83c3e..0000000 --- a/addons/gut/gui/RunAtCursor.gd +++ /dev/null @@ -1,153 +0,0 @@ -tool -extends Control - - -var ScriptTextEditors = load('res://addons/gut/gui/script_text_editor_controls.gd') - -onready var _ctrls = { - btn_script = $HBox/BtnRunScript, - btn_inner = $HBox/BtnRunInnerClass, - btn_method = $HBox/BtnRunMethod, - lbl_none = $HBox/LblNoneSelected, - arrow_1 = $HBox/Arrow1, - arrow_2 = $HBox/Arrow2 -} - -var _editors = null -var _cur_editor = null -var _last_line = -1 -var _cur_script_path = null -var _last_info = null - -signal run_tests(what) - - -func _ready(): - _ctrls.lbl_none.visible = true - _ctrls.btn_script.visible = false - _ctrls.btn_inner.visible = false - _ctrls.btn_method.visible = false - -# ---------------- -# Private -# ---------------- -func _set_editor(which): - _last_line = -1 - if(_cur_editor != null and _cur_editor.get_ref()): - _cur_editor.get_ref().disconnect('cursor_changed', self, '_on_cursor_changed') - - if(which != null): - _cur_editor = weakref(which) - which.connect('cursor_changed', self, '_on_cursor_changed', [which]) - - _last_line = which.cursor_get_line() - _last_info = _editors.get_line_info() - _update_buttons(_last_info) - - -func _update_buttons(info): - _ctrls.lbl_none.visible = _cur_script_path == null - _ctrls.btn_script.visible = _cur_script_path != null - - _ctrls.btn_inner.visible = info.inner_class != null - _ctrls.arrow_1.visible = info.inner_class != null - _ctrls.btn_inner.text = str(info.inner_class) - _ctrls.btn_inner.hint_tooltip = str("Run all tests in Inner-Test-Class ", info.inner_class) - - _ctrls.btn_method.visible = info.test_method != null - _ctrls.arrow_2.visible = info.test_method != null - _ctrls.btn_method.text = str(info.test_method) - _ctrls.btn_method.hint_tooltip = str("Run test ", info.test_method) - - # The button's new size won't take effect until the next frame. - # This appears to be what was causing the button to not be clickable the - # first time. - call_deferred("_update_rect_size") - - -func _update_rect_size(): - rect_min_size.x = _ctrls.btn_method.rect_size.x + _ctrls.btn_method.rect_position.x - -# ---------------- -# Events -# ---------------- -func _on_cursor_changed(which): - if(which.cursor_get_line() != _last_line): - _last_line = which.cursor_get_line() - _last_info = _editors.get_line_info() - _update_buttons(_last_info) - - -func _on_BtnRunScript_pressed(): - var info = _last_info.duplicate() - info.script = _cur_script_path.get_file() - info.inner_class = null - info.test_method = null - emit_signal("run_tests", info) - - -func _on_BtnRunInnerClass_pressed(): - var info = _last_info.duplicate() - info.script = _cur_script_path.get_file() - info.test_method = null - emit_signal("run_tests", info) - - -func _on_BtnRunMethod_pressed(): - var info = _last_info.duplicate() - info.script = _cur_script_path.get_file() - emit_signal("run_tests", info) - - -# ---------------- -# Public -# ---------------- -func set_script_text_editors(value): - _editors = value - - -func activate_for_script(path): - _ctrls.btn_script.visible = true - _ctrls.btn_script.text = path.get_file() - _ctrls.btn_script.hint_tooltip = str("Run all tests in script ", path) - _cur_script_path = path - _editors.refresh() - _set_editor(_editors.get_current_text_edit()) - - -func get_script_button(): - return _ctrls.btn_script - - -func get_inner_button(): - return _ctrls.btn_inner - - -func get_test_button(): - return _ctrls.btn_method - - -# not used, thought was configurable but it's just the script prefix -func set_method_prefix(value): - _editors.set_method_prefix(value) - - -# not used, thought was configurable but it's just the script prefix -func set_inner_class_prefix(value): - _editors.set_inner_class_prefix(value) - - -# Mashed this function in here b/c it has _editors. Probably should be -# somewhere else (possibly in script_text_editor_controls). -func search_current_editor_for_text(txt): - var te = _editors.get_current_text_edit() - var result = te.search(txt, 0, 0, 0) - var to_return = -1 - - if result.size() > 0: - to_return = result[TextEdit.SEARCH_RESULT_LINE] - - return to_return - - - diff --git a/addons/gut/gui/RunAtCursor.tscn b/addons/gut/gui/RunAtCursor.tscn deleted file mode 100644 index b4662df..0000000 --- a/addons/gut/gui/RunAtCursor.tscn +++ /dev/null @@ -1,80 +0,0 @@ -[gd_scene load_steps=4 format=2] - -[ext_resource path="res://addons/gut/gui/RunAtCursor.gd" type="Script" id=1] -[ext_resource path="res://addons/gut/gui/play.png" type="Texture" id=2] -[ext_resource path="res://addons/gut/gui/arrow.png" type="Texture" id=3] - -[node name="RunAtCursor" type="Control"] -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_right = 1.0 -margin_bottom = -527.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="HBox" type="HBoxContainer" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="LblNoneSelected" type="Label" parent="HBox"] -margin_top = 29.0 -margin_right = 50.0 -margin_bottom = 43.0 -text = "" - -[node name="BtnRunScript" type="Button" parent="HBox"] -visible = false -margin_left = 54.0 -margin_right = 140.0 -margin_bottom = 73.0 -text = "