✨ Added VariableGetter functionality and some Variable setting components. Also added them to test scene.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
@@ -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"]
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Low_Code.Variables;
|
||||
|
||||
/// <summary>
|
||||
/// An active getter component for calling the payload value of a <see cref="VariableResource"/>.
|
||||
/// </summary>
|
||||
public partial class VariableGetter : Node
|
||||
{
|
||||
/// <summary>
|
||||
/// The event resource to listen to.
|
||||
/// </summary>
|
||||
[Export] private VariableResource _variableResource;
|
||||
|
||||
/// <summary>
|
||||
/// A signal that is triggered when the payload of one of the <see cref="VariableResource"/> is called.
|
||||
/// </summary>
|
||||
[Signal] public delegate void GetPayloadEventHandler(Variant payload);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Variant payload of a VariableResource on demand.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Variant Get()
|
||||
{
|
||||
Variant payload = _variableResource.Payload;
|
||||
EmitSignal(SignalName.GetPayload, payload);
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://34okoih6wkmu
|
||||
@@ -3,6 +3,9 @@ using Godot.Collections;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Low_Code.Variables;
|
||||
|
||||
/// <summary>
|
||||
/// A passive Node that listens to valuechange-events on a <see cref="VariableResource"/>.
|
||||
/// </summary>
|
||||
public partial class VariableListener : Node
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,9 @@ using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Low_Code.Variables;
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="Variant"/> value wrapper resource used to store state values and notify ingame scripts.
|
||||
/// </summary>
|
||||
[GlobalClass]
|
||||
public partial class VariableResource : Resource
|
||||
{
|
||||
@@ -11,6 +14,10 @@ public partial class VariableResource : Resource
|
||||
/// </summary>
|
||||
[Export] private bool _showLog;
|
||||
|
||||
/// <summary>
|
||||
/// Public property that manages the access to the payload.
|
||||
/// Triggers the ValueChange-function when set to a new value.
|
||||
/// </summary>
|
||||
[Export]
|
||||
public Variant Payload
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://d1y23ytkt1w2j
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dco37q6ddm8kv
|
||||
Reference in New Issue
Block a user