-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
125 changed files
with
16,119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
extends Node2D | ||
# ############################################################################## | ||
# This is a wrapper around the normal and compact gui controls and serves as | ||
# the interface between gut.gd and the gui. The GutRunner creates an instance | ||
# of this and then this takes care of managing the different GUI controls. | ||
# ############################################################################## | ||
@onready var _normal_gui = $Normal | ||
@onready var _compact_gui = $Compact | ||
|
||
var gut = null : | ||
set(val): | ||
gut = val | ||
_set_gut(val) | ||
|
||
|
||
func _ready(): | ||
_normal_gui.switch_modes.connect(use_compact_mode.bind(true)) | ||
_compact_gui.switch_modes.connect(use_compact_mode.bind(false)) | ||
|
||
_normal_gui.set_title("GUT") | ||
_compact_gui.set_title("GUT") | ||
|
||
_normal_gui.align_right() | ||
_compact_gui.to_bottom_right() | ||
|
||
use_compact_mode(false) | ||
|
||
if(get_parent() == get_tree().root): | ||
_test_running_setup() | ||
|
||
func _test_running_setup(): | ||
set_font_size(100) | ||
_normal_gui.get_textbox().text = "hello world, how are you doing?" | ||
|
||
# ------------------------ | ||
# Private | ||
# ------------------------ | ||
func _set_gut(val): | ||
if(_normal_gui.get_gut() == val): | ||
return | ||
_normal_gui.set_gut(val) | ||
_compact_gui.set_gut(val) | ||
|
||
val.start_run.connect(_on_gut_start_run) | ||
val.end_run.connect(_on_gut_end_run) | ||
val.start_pause_before_teardown.connect(_on_gut_pause) | ||
val.end_pause_before_teardown.connect(_on_pause_end) | ||
|
||
func _set_both_titles(text): | ||
_normal_gui.set_title(text) | ||
_compact_gui.set_title(text) | ||
|
||
|
||
# ------------------------ | ||
# Events | ||
# ------------------------ | ||
func _on_gut_start_run(): | ||
_set_both_titles('Running') | ||
|
||
func _on_gut_end_run(): | ||
_set_both_titles('Finished') | ||
|
||
func _on_gut_pause(): | ||
_set_both_titles('-- Paused --') | ||
|
||
func _on_pause_end(): | ||
_set_both_titles('Running') | ||
|
||
|
||
# ------------------------ | ||
# Public | ||
# ------------------------ | ||
func get_textbox(): | ||
return _normal_gui.get_textbox() | ||
|
||
|
||
func set_font_size(new_size): | ||
var rtl = _normal_gui.get_textbox() | ||
|
||
rtl.set('theme_override_font_sizes/bold_italics_font_size', new_size) | ||
rtl.set('theme_override_font_sizes/bold_font_size', new_size) | ||
rtl.set('theme_override_font_sizes/italics_font_size', new_size) | ||
rtl.set('theme_override_font_sizes/normal_font_size', new_size) | ||
|
||
|
||
func set_font(font_name): | ||
_set_all_fonts_in_rtl(_normal_gui.get_textbox(), font_name) | ||
|
||
|
||
func _set_font(rtl, font_name, custom_name): | ||
if(font_name == null): | ||
rtl.remove_theme_font_override(custom_name) | ||
else: | ||
var dyn_font = FontFile.new() | ||
dyn_font.load_dynamic_font('res://addons/gut/fonts/' + font_name + '.ttf') | ||
rtl.add_theme_font_override(custom_name, dyn_font) | ||
|
||
|
||
func _set_all_fonts_in_rtl(rtl, base_name): | ||
if(base_name == 'Default'): | ||
_set_font(rtl, null, 'normal_font') | ||
_set_font(rtl, null, 'bold_font') | ||
_set_font(rtl, null, 'italics_font') | ||
_set_font(rtl, null, 'bold_italics_font') | ||
else: | ||
_set_font(rtl, base_name + '-Regular', 'normal_font') | ||
_set_font(rtl, base_name + '-Bold', 'bold_font') | ||
_set_font(rtl, base_name + '-Italic', 'italics_font') | ||
_set_font(rtl, base_name + '-BoldItalic', 'bold_italics_font') | ||
|
||
|
||
func set_default_font_color(color): | ||
_normal_gui.get_textbox().set('custom_colors/default_color', color) | ||
|
||
|
||
func set_background_color(color): | ||
_normal_gui.set_bg_color(color) | ||
|
||
|
||
func use_compact_mode(should=true): | ||
_compact_gui.visible = should | ||
_normal_gui.visible = !should | ||
|
||
|
||
func set_opacity(val): | ||
_normal_gui.modulate.a = val | ||
_compact_gui.modulate.a = val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[gd_scene load_steps=4 format=3 uid="uid://m28heqtswbuq"] | ||
|
||
[ext_resource type="Script" path="res://addons/gut/GutScene.gd" id="1_b4m8y"] | ||
[ext_resource type="PackedScene" uid="uid://duxblir3vu8x7" path="res://addons/gut/gui/NormalGui.tscn" id="2_j6ywb"] | ||
[ext_resource type="PackedScene" uid="uid://cnqqdfsn80ise" path="res://addons/gut/gui/MinGui.tscn" id="3_3glw1"] | ||
|
||
[node name="GutScene" type="Node2D"] | ||
script = ExtResource("1_b4m8y") | ||
|
||
[node name="Normal" parent="." instance=ExtResource("2_j6ywb")] | ||
|
||
[node name="Compact" parent="." instance=ExtResource("3_3glw1")] | ||
offset_left = 5.0 | ||
offset_top = 273.0 | ||
offset_right = 265.0 | ||
offset_bottom = 403.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
===================== | ||
|
||
Copyright (c) 2018 Tom "Butch" Wesley | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
extends Window | ||
|
||
@onready var rtl = $TextDisplay/RichTextLabel | ||
|
||
func _get_file_as_text(path): | ||
var to_return = null | ||
var f = FileAccess.open(path, FileAccess.READ) | ||
if(f != null): | ||
to_return = f.get_as_text() | ||
else: | ||
to_return = str('ERROR: Could not open file. Error code ', FileAccess.get_open_error()) | ||
return to_return | ||
|
||
func _ready(): | ||
rtl.clear() | ||
|
||
func _on_OpenFile_pressed(): | ||
$FileDialog.popup_centered() | ||
|
||
func _on_FileDialog_file_selected(path): | ||
show_file(path) | ||
|
||
func _on_Close_pressed(): | ||
self.hide() | ||
|
||
func show_file(path): | ||
var text = _get_file_as_text(path) | ||
if(text == ''): | ||
text = '<Empty File>' | ||
rtl.set_text(text) | ||
self.window_title = path | ||
|
||
func show_open(): | ||
self.popup_centered() | ||
$FileDialog.popup_centered() | ||
|
||
func get_rich_text_label(): | ||
return $TextDisplay/RichTextLabel | ||
|
||
func _on_Home_pressed(): | ||
rtl.scroll_to_line(0) | ||
|
||
func _on_End_pressed(): | ||
rtl.scroll_to_line(rtl.get_line_count() -1) | ||
|
||
func _on_Copy_pressed(): | ||
return | ||
# OS.clipboard = rtl.text | ||
|
||
func _on_file_dialog_visibility_changed(): | ||
if rtl.text.length() == 0 and not $FileDialog.visible: | ||
self.hide() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://bsm7wtt1gie4v"] | ||
|
||
[ext_resource type="Script" path="res://addons/gut/UserFileViewer.gd" id="1"] | ||
|
||
[node name="UserFileViewer" type="Window"] | ||
exclusive = true | ||
script = ExtResource("1") | ||
|
||
[node name="FileDialog" type="FileDialog" parent="."] | ||
access = 1 | ||
show_hidden_files = true | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="TextDisplay" type="ColorRect" parent="."] | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_left = 8.0 | ||
offset_right = -10.0 | ||
offset_bottom = -65.0 | ||
color = Color(0.2, 0.188235, 0.188235, 1) | ||
|
||
[node name="RichTextLabel" type="RichTextLabel" parent="TextDisplay"] | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
focus_mode = 2 | ||
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. | ||
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. | ||
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." | ||
selection_enabled = true | ||
|
||
[node name="OpenFile" type="Button" parent="."] | ||
anchor_left = 1.0 | ||
anchor_top = 1.0 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_left = -158.0 | ||
offset_top = -50.0 | ||
offset_right = -84.0 | ||
offset_bottom = -30.0 | ||
text = "Open File" | ||
|
||
[node name="Home" type="Button" parent="."] | ||
anchor_left = 1.0 | ||
anchor_top = 1.0 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_left = -478.0 | ||
offset_top = -50.0 | ||
offset_right = -404.0 | ||
offset_bottom = -30.0 | ||
text = "Home" | ||
|
||
[node name="Copy" type="Button" parent="."] | ||
anchor_top = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_left = 160.0 | ||
offset_top = -50.0 | ||
offset_right = 234.0 | ||
offset_bottom = -30.0 | ||
text = "Copy" | ||
|
||
[node name="End" type="Button" parent="."] | ||
anchor_left = 1.0 | ||
anchor_top = 1.0 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_left = -318.0 | ||
offset_top = -50.0 | ||
offset_right = -244.0 | ||
offset_bottom = -30.0 | ||
text = "End" | ||
|
||
[node name="Close" type="Button" parent="."] | ||
anchor_top = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_left = 10.0 | ||
offset_top = -50.0 | ||
offset_right = 80.0 | ||
offset_bottom = -30.0 | ||
text = "Close" | ||
|
||
[connection signal="file_selected" from="FileDialog" to="." method="_on_FileDialog_file_selected"] | ||
[connection signal="visibility_changed" from="FileDialog" to="." method="_on_file_dialog_visibility_changed"] | ||
[connection signal="pressed" from="OpenFile" to="." method="_on_OpenFile_pressed"] | ||
[connection signal="pressed" from="Home" to="." method="_on_Home_pressed"] | ||
[connection signal="pressed" from="Copy" to="." method="_on_Copy_pressed"] | ||
[connection signal="pressed" from="End" to="." method="_on_End_pressed"] | ||
[connection signal="pressed" from="Close" to="." method="_on_Close_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# ############################################################################## | ||
#(G)odot (U)nit (T)est class | ||
# | ||
# ############################################################################## | ||
# The MIT License (MIT) | ||
# ===================== | ||
# | ||
# Copyright (c) 2020 Tom "Butch" Wesley | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# | ||
# ############################################################################## | ||
# Class used to keep track of objects to be freed and utilities to free them. | ||
# ############################################################################## | ||
var _to_free = [] | ||
var _to_queue_free = [] | ||
|
||
func add_free(thing): | ||
if(typeof(thing) == TYPE_OBJECT): | ||
if(!thing is RefCounted): | ||
_to_free.append(thing) | ||
|
||
func add_queue_free(thing): | ||
_to_queue_free.append(thing) | ||
|
||
func get_queue_free_count(): | ||
return _to_queue_free.size() | ||
|
||
func get_free_count(): | ||
return _to_free.size() | ||
|
||
func free_all(): | ||
for i in range(_to_free.size()): | ||
if(is_instance_valid(_to_free[i])): | ||
_to_free[i].free() | ||
_to_free.clear() | ||
|
||
for i in range(_to_queue_free.size()): | ||
if(is_instance_valid(_to_queue_free[i])): | ||
_to_queue_free[i].queue_free() | ||
_to_queue_free.clear() | ||
|
||
|
Oops, something went wrong.