Skip to content

Commit d743fb1

Browse files
committed
Update to Godot 4.0
1 parent ebcdccc commit d743fb1

File tree

205 files changed

+18545
-1199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+18545
-1199
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.godot
2+
.import/
3+
export.cfg
4+
export_presets.cfg

demo/.gut_editor_config.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"background_color": "262626ff",
3+
"compact_mode": false,
4+
"config_file": "res://.gutconfig.json",
5+
"dirs": [
6+
"res://tests"
7+
],
8+
"disable_colors": false,
9+
"double_strategy": "partial",
10+
"font_color": "ccccccff",
11+
"font_name": "CourierPrime",
12+
"font_size": 16,
13+
"gut_on_top": true,
14+
"hide_orphans": false,
15+
"ignore_pause": false,
16+
"include_subdirs": true,
17+
"inner_class": null,
18+
"junit_xml_file": "",
19+
"junit_xml_timestamp": false,
20+
"log_level": 1,
21+
"opacity": 100,
22+
"paint_after": 0.1,
23+
"panel_options": {
24+
"font_name": "CourierPrime",
25+
"font_size": 30,
26+
"hide_output_text": true,
27+
"hide_result_tree": false,
28+
"hide_settings": true,
29+
"use_colors": false
30+
},
31+
"post_run_script": "",
32+
"pre_run_script": "",
33+
"prefix": "test_",
34+
"selected": null,
35+
"should_exit": false,
36+
"should_exit_on_success": false,
37+
"should_maximize": false,
38+
"show_help": false,
39+
"suffix": ".gd",
40+
"tests": [],
41+
"unit_test_name": null
42+
}

demo/addons/gut/GutScene.gd

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
extends Node2D
2+
# ##############################################################################
3+
# This is a wrapper around the normal and compact gui controls and serves as
4+
# the interface between gut.gd and the gui. The GutRunner creates an instance
5+
# of this and then this takes care of managing the different GUI controls.
6+
# ##############################################################################
7+
@onready var _normal_gui = $Normal
8+
@onready var _compact_gui = $Compact
9+
var gut = null :
10+
set(val):
11+
gut = val
12+
_set_gut(val)
13+
14+
15+
func _ready():
16+
_normal_gui.switch_modes.connect(use_compact_mode.bind(true))
17+
_compact_gui.switch_modes.connect(use_compact_mode.bind(false))
18+
19+
_normal_gui.set_title("GUT")
20+
_compact_gui.set_title("GUT")
21+
22+
_normal_gui.align_right()
23+
_compact_gui.to_bottom_right()
24+
25+
use_compact_mode(false)
26+
27+
if(get_parent() == get_tree().root):
28+
_test_running_setup()
29+
30+
func _test_running_setup():
31+
_normal_gui.get_textbox().text = "hello world, how are you doing?"
32+
33+
# ------------------------
34+
# Private
35+
# ------------------------
36+
func _set_gut(val):
37+
_normal_gui.set_gut(val)
38+
_compact_gui.set_gut(val)
39+
40+
val.start_run.connect(_on_gut_start_run)
41+
val.end_run.connect(_on_gut_end_run)
42+
val.start_pause_before_teardown.connect(_on_gut_pause)
43+
val.end_pause_before_teardown.connect(_on_pause_end)
44+
45+
func _set_both_titles(text):
46+
_normal_gui.set_title(text)
47+
_compact_gui.set_title(text)
48+
49+
50+
# ------------------------
51+
# Events
52+
# ------------------------
53+
func _on_gut_start_run():
54+
_set_both_titles('Running')
55+
56+
func _on_gut_end_run():
57+
_set_both_titles('Finished')
58+
59+
func _on_gut_pause():
60+
_set_both_titles('-- Paused --')
61+
62+
func _on_pause_end():
63+
_set_both_titles('Running')
64+
65+
66+
# ------------------------
67+
# Public
68+
# ------------------------
69+
func get_textbox():
70+
return _normal_gui.get_textbox()
71+
72+
73+
func set_font_size(new_size):
74+
return
75+
var rtl = _normal_gui.get_textbox()
76+
if(rtl.get('custom_fonts/normal_font') != null):
77+
rtl.get('custom_fonts/bold_italics_font').size = new_size
78+
rtl.get('custom_fonts/bold_font').size = new_size
79+
rtl.get('custom_fonts/italics_font').size = new_size
80+
rtl.get('custom_fonts/normal_font').size = new_size
81+
82+
83+
func set_font(font_name):
84+
_set_all_fonts_in_rtl(_normal_gui.get_textbox(), font_name)
85+
86+
87+
func _set_font(rtl, font_name, custom_name):
88+
if(font_name == null):
89+
rtl.add_theme_font_override(custom_name, null)
90+
else:
91+
var dyn_font = FontFile.new()
92+
dyn_font.load_dynamic_font('res://addons/gut/fonts/' + font_name + '.ttf')
93+
rtl.add_theme_font_override(custom_name, dyn_font)
94+
95+
96+
func _set_all_fonts_in_rtl(rtl, base_name):
97+
if(base_name == 'Default'):
98+
_set_font(rtl, null, 'normal_font')
99+
_set_font(rtl, null, 'bold_font')
100+
_set_font(rtl, null, 'italics_font')
101+
_set_font(rtl, null, 'bold_italics_font')
102+
else:
103+
_set_font(rtl, base_name + '-Regular', 'normal_font')
104+
_set_font(rtl, base_name + '-Bold', 'bold_font')
105+
_set_font(rtl, base_name + '-Italic', 'italics_font')
106+
_set_font(rtl, base_name + '-BoldItalic', 'bold_italics_font')
107+
108+
109+
func set_default_font_color(color):
110+
_normal_gui.get_textbox().set('custom_colors/default_color', color)
111+
112+
113+
func set_background_color(color):
114+
_normal_gui.set_bg_color(color)
115+
116+
117+
func use_compact_mode(should=true):
118+
_compact_gui.visible = should
119+
_normal_gui.visible = !should
120+
121+
122+
func set_opacity(val):
123+
_normal_gui.modulate.a = val
124+
_compact_gui.modulate.a = val

demo/addons/gut/GutScene.tscn

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[gd_scene load_steps=4 format=3 uid="uid://m28heqtswbuq"]
2+
3+
[ext_resource type="Script" path="res://addons/gut/GutScene.gd" id="1_b4m8y"]
4+
[ext_resource type="PackedScene" uid="uid://duxblir3vu8x7" path="res://addons/gut/gui/NormalGui.tscn" id="2_j6ywb"]
5+
[ext_resource type="PackedScene" uid="uid://cnqqdfsn80ise" path="res://addons/gut/gui/MinGui.tscn" id="3_3glw1"]
6+
7+
[node name="GutScene" type="Node2D"]
8+
script = ExtResource("1_b4m8y")
9+
10+
[node name="Normal" parent="." instance=ExtResource("2_j6ywb")]
11+
12+
[node name="Compact" parent="." instance=ExtResource("3_3glw1")]
13+
offset_left = 5.0
14+
offset_top = 273.0
15+
offset_right = 265.0
16+
offset_bottom = 403.0

demo/addons/gut/LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
=====================
3+
4+
Copyright (c) 2018 Tom "Butch" Wesley
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

demo/addons/gut/UserFileViewer.gd

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
extends Window
2+
3+
@onready var rtl = $TextDisplay/RichTextLabel
4+
5+
func _get_file_as_text(path):
6+
var to_return = null
7+
var f = FileAccess.open(path, FileAccess.READ)
8+
if(f != null):
9+
to_return = f.get_as_text()
10+
else:
11+
to_return = str('ERROR: Could not open file. Error code ', FileAccess.get_open_error())
12+
return to_return
13+
14+
func _ready():
15+
rtl.clear()
16+
17+
func _on_OpenFile_pressed():
18+
$FileDialog.popup_centered()
19+
20+
func _on_FileDialog_file_selected(path):
21+
show_file(path)
22+
23+
func _on_Close_pressed():
24+
self.hide()
25+
26+
func show_file(path):
27+
var text = _get_file_as_text(path)
28+
if(text == ''):
29+
text = '<Empty File>'
30+
rtl.set_text(text)
31+
self.window_title = path
32+
33+
func show_open():
34+
self.popup_centered()
35+
$FileDialog.popup_centered()
36+
37+
func get_rich_text_label():
38+
return $TextDisplay/RichTextLabel
39+
40+
func _on_Home_pressed():
41+
rtl.scroll_to_line(0)
42+
43+
func _on_End_pressed():
44+
rtl.scroll_to_line(rtl.get_line_count() -1)
45+
46+
func _on_Copy_pressed():
47+
return
48+
# OS.clipboard = rtl.text
49+
50+
func _on_file_dialog_visibility_changed():
51+
if rtl.text.length() == 0 and not $FileDialog.visible:
52+
self.hide()

demo/addons/gut/UserFileViewer.tscn

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://bsm7wtt1gie4v"]
2+
3+
[ext_resource type="Script" path="res://addons/gut/UserFileViewer.gd" id="1"]
4+
5+
[node name="UserFileViewer" type="Window"]
6+
exclusive = true
7+
script = ExtResource("1")
8+
9+
[node name="FileDialog" type="FileDialog" parent="."]
10+
access = 1
11+
show_hidden_files = true
12+
__meta__ = {
13+
"_edit_use_anchors_": false
14+
}
15+
16+
[node name="TextDisplay" type="ColorRect" parent="."]
17+
anchor_right = 1.0
18+
anchor_bottom = 1.0
19+
offset_left = 8.0
20+
offset_right = -10.0
21+
offset_bottom = -65.0
22+
color = Color(0.2, 0.188235, 0.188235, 1)
23+
24+
[node name="RichTextLabel" type="RichTextLabel" parent="TextDisplay"]
25+
anchor_right = 1.0
26+
anchor_bottom = 1.0
27+
focus_mode = 2
28+
text = "In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content. Lorem ipsum may be used before final copy is available, but it may also be used to temporarily replace copy in a process called greeking, which allows designers to consider form without the meaning of the text influencing the design.
29+
30+
Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a first-century BCE text by the Roman statesman and philosopher Cicero, with words altered, added, and removed to make it nonsensical, improper Latin.
31+
32+
Versions of the Lorem ipsum text have been used in typesetting at least since the 1960s, when it was popularized by advertisements for Letraset transfer sheets. Lorem ipsum was introduced to the digital world in the mid-1980s when Aldus employed it in graphic and word-processing templates for its desktop publishing program PageMaker. Other popular word processors including Pages and Microsoft Word have since adopted Lorem ipsum as well."
33+
selection_enabled = true
34+
35+
[node name="OpenFile" type="Button" parent="."]
36+
anchor_left = 1.0
37+
anchor_top = 1.0
38+
anchor_right = 1.0
39+
anchor_bottom = 1.0
40+
offset_left = -158.0
41+
offset_top = -50.0
42+
offset_right = -84.0
43+
offset_bottom = -30.0
44+
text = "Open File"
45+
46+
[node name="Home" type="Button" parent="."]
47+
anchor_left = 1.0
48+
anchor_top = 1.0
49+
anchor_right = 1.0
50+
anchor_bottom = 1.0
51+
offset_left = -478.0
52+
offset_top = -50.0
53+
offset_right = -404.0
54+
offset_bottom = -30.0
55+
text = "Home"
56+
57+
[node name="Copy" type="Button" parent="."]
58+
anchor_top = 1.0
59+
anchor_bottom = 1.0
60+
offset_left = 160.0
61+
offset_top = -50.0
62+
offset_right = 234.0
63+
offset_bottom = -30.0
64+
text = "Copy"
65+
66+
[node name="End" type="Button" parent="."]
67+
anchor_left = 1.0
68+
anchor_top = 1.0
69+
anchor_right = 1.0
70+
anchor_bottom = 1.0
71+
offset_left = -318.0
72+
offset_top = -50.0
73+
offset_right = -244.0
74+
offset_bottom = -30.0
75+
text = "End"
76+
77+
[node name="Close" type="Button" parent="."]
78+
anchor_top = 1.0
79+
anchor_bottom = 1.0
80+
offset_left = 10.0
81+
offset_top = -50.0
82+
offset_right = 80.0
83+
offset_bottom = -30.0
84+
text = "Close"
85+
86+
[connection signal="file_selected" from="FileDialog" to="." method="_on_FileDialog_file_selected"]
87+
[connection signal="visibility_changed" from="FileDialog" to="." method="_on_file_dialog_visibility_changed"]
88+
[connection signal="pressed" from="OpenFile" to="." method="_on_OpenFile_pressed"]
89+
[connection signal="pressed" from="Home" to="." method="_on_Home_pressed"]
90+
[connection signal="pressed" from="Copy" to="." method="_on_Copy_pressed"]
91+
[connection signal="pressed" from="End" to="." method="_on_End_pressed"]
92+
[connection signal="pressed" from="Close" to="." method="_on_Close_pressed"]

0 commit comments

Comments
 (0)