Adding log.gd

This commit is contained in:
Dan Baker 2024-05-02 09:36:31 +01:00
parent eb32d6614e
commit 4522259397
547 changed files with 46844 additions and 0 deletions

View file

@ -0,0 +1,39 @@
class_name Spell
extends Node
signal spell_explode
const SPELL_LIVE_TIME = 1000
@warning_ignore("unused_private_class_variable")
var _spell_fired :bool = false
var _spell_live_time :float = 0
var _spell_pos :Vector3 = Vector3.ZERO
# helper counter for testing simulate_frames
@warning_ignore("unused_private_class_variable")
var _debug_process_counted := 0
func _ready():
set_name("Spell")
# only comment in for debugging reasons
#func _notification(what):
# prints("Spell", GdObjects.notification_as_string(what))
func _process(delta :float):
# added pseudo yield to check `simulate_frames` works wih custom yielding
await get_tree().process_frame
_spell_live_time += delta * 1000
if _spell_live_time < SPELL_LIVE_TIME:
move(delta)
else:
explode()
func move(delta :float) -> void:
#await get_tree().create_timer(0.1).timeout
_spell_pos.x += delta
func explode() -> void:
emit_signal("spell_explode", self)

View file

@ -0,0 +1,104 @@
extends Control
signal panel_color_change(box, color)
const COLOR_CYCLE := [Color.ROYAL_BLUE, Color.CHARTREUSE, Color.YELLOW_GREEN]
@onready var _box1 = $VBoxContainer/PanelContainer/HBoxContainer/Panel1
@onready var _box2 = $VBoxContainer/PanelContainer/HBoxContainer/Panel2
@onready var _box3 = $VBoxContainer/PanelContainer/HBoxContainer/Panel3
@warning_ignore("unused_private_class_variable")
@export var _initial_color := Color.RED
@warning_ignore("unused_private_class_variable")
var _nullable :Object
func _ready():
connect("panel_color_change", _on_panel_color_changed)
# we call this function to verify the _ready is only once called
# this is need to verify `add_child` is calling the original implementation only once
only_one_time_call()
func only_one_time_call() -> void:
pass
#func _notification(what):
# prints("TestScene", GdObjects.notification_as_string(what))
func _on_test_pressed(button_id :int):
var box :ColorRect
match button_id:
1: box = _box1
2: box = _box2
3: box = _box3
emit_signal("panel_color_change", box, Color.RED)
# special case for button 3 we wait 1s to change to gray
if button_id == 3:
await get_tree().create_timer(1).timeout
emit_signal("panel_color_change", box, Color.GRAY)
func _on_panel_color_changed(box :ColorRect, color :Color):
box.color = color
func create_timer(timeout :float) -> Timer:
var timer :Timer = Timer.new()
add_child(timer)
timer.connect("timeout",Callable(self,"_on_timeout").bind(timer))
timer.set_one_shot(true)
timer.start(timeout)
return timer
func _on_timeout(timer :Timer):
remove_child(timer)
timer.queue_free()
func color_cycle() -> String:
prints("color_cycle")
await create_timer(0.500).timeout
emit_signal("panel_color_change", _box1, Color.RED)
prints("timer1")
await create_timer(0.500).timeout
emit_signal("panel_color_change", _box1, Color.BLUE)
prints("timer2")
await create_timer(0.500).timeout
emit_signal("panel_color_change", _box1, Color.GREEN)
prints("cycle end")
return "black"
func start_color_cycle():
color_cycle()
# used for manuall spy checked created spy
func _create_spell() -> Spell:
return Spell.new()
func create_spell() -> Spell:
var spell := _create_spell()
spell.connect("spell_explode", Callable(self, "_destroy_spell"))
return spell
func _destroy_spell(spell :Spell) -> void:
#prints("_destroy_spell", spell)
remove_child(spell)
spell.queue_free()
func _input(event):
if event.is_action_released("ui_accept"):
add_child(create_spell())
func add(a: int, b :int) -> int:
return a + b

View file

@ -0,0 +1,104 @@
[gd_scene load_steps=2 format=3 uid="uid://bf24pr1xj60o6"]
[ext_resource type="Script" path="res://addons/gdUnit4/test/mocker/resources/scenes/TestScene.gd" id="1"]
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
custom_minimum_size = Vector2(0, 40)
layout_mode = 2
[node name="test1" type="Button" parent="VBoxContainer/HBoxContainer"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
text = "Test 1"
[node name="test2" type="Button" parent="VBoxContainer/HBoxContainer"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
text = "Test 2"
[node name="test3" type="Button" parent="VBoxContainer/HBoxContainer"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
text = "Test 3"
[node name="PanelContainer" type="TabContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer"]
layout_mode = 2
[node name="Panel1" type="ColorRect" parent="VBoxContainer/PanelContainer/HBoxContainer"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/HBoxContainer/Panel1"]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 14.0
grow_horizontal = 2
text = "Panel 1"
[node name="Panel2" type="ColorRect" parent="VBoxContainer/PanelContainer/HBoxContainer"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/HBoxContainer/Panel2"]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 14.0
grow_horizontal = 2
text = "Panel 2"
[node name="Panel3" type="ColorRect" parent="VBoxContainer/PanelContainer/HBoxContainer"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/HBoxContainer/Panel3"]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 14.0
grow_horizontal = 2
text = "Panel 3"
[node name="Line2D" type="Line2D" parent="VBoxContainer"]
points = PackedVector2Array(0, 0, 20, 0)
width = 30.0
default_color = Color(1, 0.0509804, 0.192157, 1)
[node name="Line2D2" type="Line2D" parent="VBoxContainer"]
points = PackedVector2Array(20, 0, 40, 0)
width = 30.0
default_color = Color(0.0392157, 1, 0.278431, 1)
[node name="Line2D3" type="Line2D" parent="VBoxContainer"]
points = PackedVector2Array(40, 0, 60, 0)
width = 30.0
default_color = Color(1, 0.0392157, 0.247059, 1)
[connection signal="pressed" from="VBoxContainer/HBoxContainer/test1" to="." method="_on_test_pressed" binds= [1]]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/test2" to="." method="_on_test_pressed" binds= [2]]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/test3" to="." method="_on_test_pressed" binds= [3]]

View file

@ -0,0 +1,67 @@
[gd_scene format=3 uid="uid://bvp8uaof31fhm"]
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="test1" type="Button" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Test 1"
[node name="test2" type="Button" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Test 2"
[node name="test3" type="Button" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Test 3"
[node name="PanelContainer" type="TabContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer"]
layout_mode = 2
[node name="Panel1" type="ColorRect" parent="VBoxContainer/PanelContainer/HBoxContainer"]
layout_mode = 2
color = Color(0.694118, 0.207843, 0.207843, 1)
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/HBoxContainer/Panel1"]
layout_mode = 0
anchor_right = 1.0
offset_bottom = 14.0
text = "Panel 1"
[node name="Panel2" type="ColorRect" parent="VBoxContainer/PanelContainer/HBoxContainer"]
layout_mode = 2
color = Color(0.219608, 0.662745, 0.380392, 1)
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/HBoxContainer/Panel2"]
layout_mode = 0
anchor_right = 1.0
offset_bottom = 14.0
text = "Panel 2"
[node name="Panel3" type="ColorRect" parent="VBoxContainer/PanelContainer/HBoxContainer"]
layout_mode = 2
color = Color(0.12549, 0.286275, 0.776471, 1)
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/HBoxContainer/Panel3"]
layout_mode = 0
anchor_right = 1.0
offset_bottom = 14.0
text = "Panel 3"