From 3fe79f2fd8f6fd5b8cadc69387d3269d41471802 Mon Sep 17 00:00:00 2001 From: kziolkowski Date: Tue, 28 Oct 2025 13:09:36 +0100 Subject: [PATCH] :sparkles: Added VariableGetter functionality and some Variable setting components. Also added them to test scene. --- project.godot | 1 + resources/low code/test/var_Counter.tres | 8 +++++ scenes/testing/eventTest.tscn | 36 ++++++++++++++++++- .../Low Code/Variables/VariableGetter.cs | 30 ++++++++++++++++ .../Low Code/Variables/VariableGetter.cs.uid | 1 + .../Low Code/Variables/VariableListener.cs | 3 ++ .../Low Code/Variables/VariableResource.cs | 7 ++++ .../VariantValueChanger/VariantIncrementor.cs | 22 ++++++++++++ .../VariantIncrementor.cs.uid | 1 + .../VariantValueChanger/VariantToString.cs | 16 +++++++++ .../VariantToString.cs.uid | 1 + 11 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 resources/low code/test/var_Counter.tres create mode 100644 scripts/CSharp/Low Code/Variables/VariableGetter.cs create mode 100644 scripts/CSharp/Low Code/Variables/VariableGetter.cs.uid create mode 100644 scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantIncrementor.cs create mode 100644 scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantIncrementor.cs.uid create mode 100644 scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantToString.cs create mode 100644 scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantToString.cs.uid diff --git a/project.godot b/project.godot index 4a1f774..6112bd3 100644 --- a/project.godot +++ b/project.godot @@ -169,6 +169,7 @@ directories/tres_directory={ "tomato_seed": "res://resources/items/tomato_seed.tres", "unselected_stylebox": "res://addons/dialogic/Editor/Events/styles/unselected_stylebox.tres", "var_ColorTestValue": "res://resources/low code/test/var_ColorTestValue.tres", +"var_Counter": "res://resources/low code/test/var_Counter.tres", "vesna_style": "res://addons/dialogic/vesna_style.tres", "vn_textbox_default_panel": "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_default_panel.tres", "vn_textbox_name_label_panel": "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_name_label_panel.tres", diff --git a/resources/low code/test/var_Counter.tres b/resources/low code/test/var_Counter.tres new file mode 100644 index 0000000..02a605b --- /dev/null +++ b/resources/low code/test/var_Counter.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" script_class="VariableResource" load_steps=2 format=3 uid="uid://c6iw30ydc0qa0"] + +[ext_resource type="Script" uid="uid://dtvx2cakx0bey" path="res://scripts/CSharp/Low Code/Variables/VariableResource.cs" id="1_sbnhb"] + +[resource] +script = ExtResource("1_sbnhb") +Payload = 0 +metadata/_custom_type_script = "uid://dtvx2cakx0bey" diff --git a/scenes/testing/eventTest.tscn b/scenes/testing/eventTest.tscn index 6a0923e..f6dae4b 100644 --- a/scenes/testing/eventTest.tscn +++ b/scenes/testing/eventTest.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://6n3p3psmxovj"] +[gd_scene load_steps=10 format=3 uid="uid://6n3p3psmxovj"] [ext_resource type="Script" uid="uid://pqemey80frcq" path="res://scripts/CSharp/Low Code/Variables/VariableListener.cs" id="1_4h3ry"] [ext_resource type="Script" uid="uid://bc6uaaxsx5k5p" path="res://scripts/CSharp/Low Code/Events/EventListener.cs" id="1_w5ykc"] @@ -6,6 +6,9 @@ [ext_resource type="Script" uid="uid://b5dotkx17gvxg" path="res://scripts/CSharp/Low Code/Events/EventRaiser.cs" id="3_bj4kf"] [ext_resource type="Resource" uid="uid://boijwlxmth68v" path="res://resources/low code/test/event_textLabelClicked.tres" id="5_4h3ry"] [ext_resource type="Script" uid="uid://co1b320qemg1i" path="res://scripts/CSharp/Low Code/Randomizer/VariantRandomizer.cs" id="5_nm8dh"] +[ext_resource type="Script" uid="uid://dco37q6ddm8kv" path="res://scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantToString.cs" id="7_nm8dh"] +[ext_resource type="Resource" uid="uid://c6iw30ydc0qa0" path="res://resources/low code/test/var_Counter.tres" id="9_44nfx"] +[ext_resource type="Script" uid="uid://d1y23ytkt1w2j" path="res://scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantIncrementor.cs" id="10_p6d2q"] [node name="EventTest" type="Node2D"] @@ -57,11 +60,42 @@ verknüpft ist]" script = ExtResource("1_w5ykc") _eventResources = Array[Object]([ExtResource("5_4h3ry")]) +[node name="LabelTextEventButton2" type="Button" parent="Control"] +layout_mode = 0 +offset_left = 361.0 +offset_top = 148.0 +offset_right = 518.0 +offset_bottom = 179.0 +text = "get current number +" + +[node name="TestLabel2" type="Label" parent="Control"] +layout_mode = 0 +offset_left = 432.0 +offset_top = 117.0 +offset_right = 472.0 +offset_bottom = 166.0 +text = "0 +" +script = ExtResource("7_nm8dh") +_resource = ExtResource("9_44nfx") + [node name="Camera2D" type="Camera2D" parent="."] position = Vector2(239, 110) zoom = Vector2(3.4, 3.4) +[node name="Timer" type="Timer" parent="."] +wait_time = 0.5 +autostart = true + +[node name="CountLoop" type="Node" parent="Timer"] +script = ExtResource("10_p6d2q") +_resource = ExtResource("9_44nfx") + [connection signal="NewEventPayload" from="Control/ColorRect" to="Control/ColorRect" method="set_color"] [connection signal="pressed" from="Control/ChangeColorButton" to="Control/ChangeColorButton" method="RandomizeEventResource"] [connection signal="pressed" from="Control/LabelTextEventButton" to="Control/LabelTextEventButton" method="RaiseEvents"] [connection signal="EventRaised" from="Control/TestLabel" to="Control/TestLabel" method="show"] +[connection signal="pressed" from="Control/LabelTextEventButton2" to="Control/TestLabel2" method="ConvertToString"] +[connection signal="PayloadAsString" from="Control/TestLabel2" to="Control/TestLabel2" method="set_text"] +[connection signal="timeout" from="Timer" to="Timer/CountLoop" method="Increment"] diff --git a/scripts/CSharp/Low Code/Variables/VariableGetter.cs b/scripts/CSharp/Low Code/Variables/VariableGetter.cs new file mode 100644 index 0000000..d5138f9 --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariableGetter.cs @@ -0,0 +1,30 @@ +using Godot; + +namespace Babushka.scripts.CSharp.Low_Code.Variables; + +/// +/// An active getter component for calling the payload value of a . +/// +public partial class VariableGetter : Node +{ + /// + /// The event resource to listen to. + /// + [Export] private VariableResource _variableResource; + + /// + /// A signal that is triggered when the payload of one of the is called. + /// + [Signal] public delegate void GetPayloadEventHandler(Variant payload); + + /// + /// Gets the Variant payload of a VariableResource on demand. + /// + /// + public Variant Get() + { + Variant payload = _variableResource.Payload; + EmitSignal(SignalName.GetPayload, payload); + return payload; + } +} \ No newline at end of file diff --git a/scripts/CSharp/Low Code/Variables/VariableGetter.cs.uid b/scripts/CSharp/Low Code/Variables/VariableGetter.cs.uid new file mode 100644 index 0000000..1a4682f --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariableGetter.cs.uid @@ -0,0 +1 @@ +uid://34okoih6wkmu diff --git a/scripts/CSharp/Low Code/Variables/VariableListener.cs b/scripts/CSharp/Low Code/Variables/VariableListener.cs index 238381f..2576015 100644 --- a/scripts/CSharp/Low Code/Variables/VariableListener.cs +++ b/scripts/CSharp/Low Code/Variables/VariableListener.cs @@ -3,6 +3,9 @@ using Godot.Collections; namespace Babushka.scripts.CSharp.Low_Code.Variables; +/// +/// A passive Node that listens to valuechange-events on a . +/// public partial class VariableListener : Node { /// diff --git a/scripts/CSharp/Low Code/Variables/VariableResource.cs b/scripts/CSharp/Low Code/Variables/VariableResource.cs index 77bc13e..20d5240 100644 --- a/scripts/CSharp/Low Code/Variables/VariableResource.cs +++ b/scripts/CSharp/Low Code/Variables/VariableResource.cs @@ -3,6 +3,9 @@ using Godot; namespace Babushka.scripts.CSharp.Low_Code.Variables; +/// +/// A value wrapper resource used to store state values and notify ingame scripts. +/// [GlobalClass] public partial class VariableResource : Resource { @@ -11,6 +14,10 @@ public partial class VariableResource : Resource /// [Export] private bool _showLog; + /// + /// Public property that manages the access to the payload. + /// Triggers the ValueChange-function when set to a new value. + /// [Export] public Variant Payload { diff --git a/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantIncrementor.cs b/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantIncrementor.cs new file mode 100644 index 0000000..3118535 --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantIncrementor.cs @@ -0,0 +1,22 @@ +using Godot; + +namespace Babushka.scripts.CSharp.Low_Code.Variables.VariantValueChanger; + +public partial class VariantIncrementor : Node +{ + [Export] private VariableResource _resource; + + public void Increment() + { + int integerValue = _resource.Payload.AsInt32(); + integerValue++; + _resource.Payload = integerValue; + } + + public void Decrement() + { + int integerValue = _resource.Payload.AsInt32(); + integerValue--; + _resource.Payload = integerValue; + } +} \ No newline at end of file diff --git a/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantIncrementor.cs.uid b/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantIncrementor.cs.uid new file mode 100644 index 0000000..f6133c0 --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantIncrementor.cs.uid @@ -0,0 +1 @@ +uid://d1y23ytkt1w2j diff --git a/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantToString.cs b/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantToString.cs new file mode 100644 index 0000000..1219487 --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantToString.cs @@ -0,0 +1,16 @@ +using Godot; + +namespace Babushka.scripts.CSharp.Low_Code.Variables.VariantValueChanger; + +public partial class VariantToString : Node +{ + [Export] private VariableResource _resource; + + [Signal] public delegate void PayloadAsStringEventHandler(string payloadAsString); + + + public void ConvertToString() + { + EmitSignal(SignalName.PayloadAsString, _resource.Payload.AsString()); + } +} \ No newline at end of file diff --git a/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantToString.cs.uid b/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantToString.cs.uid new file mode 100644 index 0000000..9aced51 --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariantValueChanger/VariantToString.cs.uid @@ -0,0 +1 @@ +uid://dco37q6ddm8kv