Compare commits
4 Commits
a593be8273
...
5cf250b295
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cf250b295 | |||
| ef56f79d5c | |||
| 5bcbee8865 | |||
| a74abe684b |
+2
-2
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Godot.NET.Sdk/4.4.0">
|
||||
<Project Sdk="Godot.NET.Sdk/4.5.1">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
@@ -6,6 +6,6 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="prefabs\UI\Inventory\" />
|
||||
<Folder Include="scripts\CSharp\Low Code\" />
|
||||
<Folder Include="scripts\CSharp\Low Code\Randomizer\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+3
-2
@@ -12,7 +12,7 @@ config_version=5
|
||||
|
||||
config/name="Babushka"
|
||||
run/main_scene="uid://bopv10dqm1knc"
|
||||
config/features=PackedStringArray("4.4", "C#", "Forward Plus")
|
||||
config/features=PackedStringArray("4.5", "C#", "Forward Plus")
|
||||
run/max_fps=120
|
||||
boot_splash/fullsize=false
|
||||
boot_splash/image="uid://utam4axkvutc"
|
||||
@@ -121,6 +121,7 @@ directories/tres_directory={
|
||||
"8_goto_bed": "res://resources/quests/demo/8_goto_bed.tres",
|
||||
"9_talk_to_chuga": "res://resources/quests/demo/9_talk_to_chuga.tres",
|
||||
"Babushka_NPC_Namebox_background": "res://dialog/Babushka_NPC_Namebox_background.tres",
|
||||
"ColorEvent": "res://resources/events/ColorEvent.tres",
|
||||
"InputFieldsStyle": "res://addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres",
|
||||
"MainTheme": "res://addons/dialogic/Editor/Theme/MainTheme.tres",
|
||||
"NPC_narrative": "res://dialog/NPC_narrative.tres",
|
||||
@@ -132,6 +133,7 @@ directories/tres_directory={
|
||||
"SectionPanel": "res://addons/dialogic/Editor/Events/styles/SectionPanel.tres",
|
||||
"SimpleButtonHover": "res://addons/dialogic/Editor/Events/styles/SimpleButtonHover.tres",
|
||||
"SimpleButtonNormal": "res://addons/dialogic/Editor/Events/styles/SimpleButtonNormal.tres",
|
||||
"TestStringEvent": "res://resources/events/TestStringEvent.tres",
|
||||
"TextBackground": "res://addons/dialogic/Editor/Events/styles/TextBackground.tres",
|
||||
"TitleBgStylebox": "res://addons/dialogic/Editor/Common/TitleBgStylebox.tres",
|
||||
"babushka_dialogue_style": "res://addons/babushkahelpers/babushka_dialogue_style.tres",
|
||||
@@ -162,7 +164,6 @@ directories/tres_directory={
|
||||
"test/test_01": "res://resources/quests/test/test_01.tres",
|
||||
"test/test_02": "res://resources/quests/test/test_02.tres",
|
||||
"test/test_03": "res://resources/quests/test/test_03.tres",
|
||||
"test2": "res://resources/events/test2.tres",
|
||||
"textbubble_style": "res://addons/dialogic/Modules/DefaultLayoutParts/Style_TextBubbles/textbubble_style.tres",
|
||||
"tomato": "res://resources/items/tomato.tres",
|
||||
"tomato_seed": "res://resources/items/tomato_seed.tres",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[gd_resource type="Resource" script_class="EventResource" load_steps=2 format=3 uid="uid://dc7e13hq47uma"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ci3t5mvnopntg" path="res://scripts/CSharp/Low Code/Events/EventResource.cs" id="1_ufwo5"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ufwo5")
|
||||
_showLog = true
|
||||
Payload = Color(0.84002423, 0.44197178, 0.5653889, 1)
|
||||
metadata/_custom_type_script = "uid://ci3t5mvnopntg"
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_resource type="Resource" script_class="EventResource" load_steps=2 format=3 uid="uid://bgfxakxxfmoxs"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ci3t5mvnopntg" path="res://scripts/CSharp/Low Code/Events/EventResource.cs" id="1_jm77s"]
|
||||
[ext_resource type="Script" uid="uid://ci3t5mvnopntg" path="res://scripts/CSharp/Low Code/Events/EventResource.cs" id="1_dd3u7"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_jm77s")
|
||||
script = ExtResource("1_dd3u7")
|
||||
_showLog = true
|
||||
Payload = "This is a test."
|
||||
metadata/_custom_type_script = "uid://ci3t5mvnopntg"
|
||||
@@ -1,11 +1,8 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://c6wnoif01ltld"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c6wnoif01ltld"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cssdu8viimwm6" path="res://scripts/CSharp/Common/SceneTransition.cs" id="1_fj2fh"]
|
||||
[ext_resource type="Script" uid="uid://b5dotkx17gvxg" path="res://scripts/CSharp/Low Code/Events/EventRaiser.cs" id="3_5a78e"]
|
||||
[ext_resource type="Texture2D" uid="uid://c7atj6ohlmir3" path="res://art/ui/StartScreen/titlescreen.png" id="3_r0y6o"]
|
||||
[ext_resource type="Resource" uid="uid://bgfxakxxfmoxs" path="res://resources/events/test2.tres" id="4_5a78e"]
|
||||
[ext_resource type="Texture2D" uid="uid://du612t3xytly3" path="res://art/ui/StartScreen/babushkalog_white.png" id="4_dl0t1"]
|
||||
[ext_resource type="Script" uid="uid://bc6uaaxsx5k5p" path="res://scripts/CSharp/Low Code/Events/EventListener.cs" id="6_5a78e"]
|
||||
|
||||
[node name="BabushkaSceneStartMenu" type="Node2D"]
|
||||
script = ExtResource("1_fj2fh")
|
||||
@@ -55,24 +52,6 @@ toggle_mode = true
|
||||
text = "Quit
|
||||
"
|
||||
|
||||
[node name="Test" type="Button" parent="CanvasLayer/TextureRect"]
|
||||
custom_minimum_size = Vector2(100, 30)
|
||||
layout_mode = 1
|
||||
anchors_preset = 4
|
||||
anchor_top = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = 205.0
|
||||
offset_top = 215.0
|
||||
offset_right = 405.0
|
||||
offset_bottom = 255.0
|
||||
grow_vertical = 2
|
||||
scale = Vector2(2, 2)
|
||||
toggle_mode = true
|
||||
text = "Test
|
||||
"
|
||||
script = ExtResource("3_5a78e")
|
||||
_eventResources = Array[Object]([ExtResource("4_5a78e")])
|
||||
|
||||
[node name="Text" type="TextureRect" parent="CanvasLayer/TextureRect"]
|
||||
layout_mode = 1
|
||||
offset_left = 50.0
|
||||
@@ -83,11 +62,5 @@ scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("4_dl0t1")
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="EventListener" type="Node" parent="."]
|
||||
script = ExtResource("6_5a78e")
|
||||
_eventResources = Array[Object]([ExtResource("4_5a78e")])
|
||||
|
||||
[connection signal="pressed" from="CanvasLayer/TextureRect/Start" to="." method="LoadScene"]
|
||||
[connection signal="pressed" from="CanvasLayer/TextureRect/Quit" to="." method="Quit"]
|
||||
[connection signal="pressed" from="CanvasLayer/TextureRect/Test" to="CanvasLayer/TextureRect/Test" method="RaiseEvents"]
|
||||
[connection signal="EventRaised" from="EventListener" to="CanvasLayer/TextureRect/Test" method="hide"]
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://6n3p3psmxovj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bc6uaaxsx5k5p" path="res://scripts/CSharp/Low Code/Events/EventListener.cs" id="1_w5ykc"]
|
||||
[ext_resource type="Resource" uid="uid://dc7e13hq47uma" path="res://resources/events/ColorEvent.tres" id="2_4h3ry"]
|
||||
[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://bgfxakxxfmoxs" path="res://resources/events/TestStringEvent.tres" id="4_5dsed"]
|
||||
[ext_resource type="Script" uid="uid://co1b320qemg1i" path="res://scripts/CSharp/Low Code/Randomizer/VariantRandomizer.cs" id="5_nm8dh"]
|
||||
|
||||
[node name="EventTest" type="Node2D"]
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_top = -1.0
|
||||
offset_right = 513.0
|
||||
offset_bottom = 329.0
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="Control"]
|
||||
layout_mode = 0
|
||||
offset_right = 178.0
|
||||
offset_bottom = 145.0
|
||||
script = ExtResource("1_w5ykc")
|
||||
_eventResources = Array[Object]([ExtResource("2_4h3ry")])
|
||||
_showLog = true
|
||||
|
||||
[node name="LabelTextEventButton" type="Button" parent="Control"]
|
||||
layout_mode = 0
|
||||
offset_left = 194.0
|
||||
offset_top = 148.0
|
||||
offset_right = 351.0
|
||||
offset_bottom = 179.0
|
||||
text = "Show Event Text
|
||||
"
|
||||
script = ExtResource("3_bj4kf")
|
||||
_eventResources = Array[Object]([ExtResource("4_5dsed")])
|
||||
|
||||
[node name="ChangeColorButton" type="Button" parent="Control"]
|
||||
layout_mode = 0
|
||||
offset_top = 148.0
|
||||
offset_right = 112.0
|
||||
offset_bottom = 179.0
|
||||
text = "Change Color
|
||||
"
|
||||
script = ExtResource("5_nm8dh")
|
||||
_eventResource = ExtResource("2_4h3ry")
|
||||
|
||||
[node name="TestLabel" type="Label" parent="Control"]
|
||||
layout_mode = 0
|
||||
offset_left = 237.0
|
||||
offset_top = 54.0
|
||||
offset_right = 277.0
|
||||
offset_bottom = 77.0
|
||||
script = ExtResource("1_w5ykc")
|
||||
_eventResources = Array[Object]([ExtResource("4_5dsed")])
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
position = Vector2(239, 110)
|
||||
zoom = Vector2(3.4, 3.4)
|
||||
|
||||
[connection signal="NewEventPayload" from="Control/ColorRect" to="Control/ColorRect" method="set_color"]
|
||||
[connection signal="pressed" from="Control/LabelTextEventButton" to="Control/LabelTextEventButton" method="RaiseEvents"]
|
||||
[connection signal="pressed" from="Control/ChangeColorButton" to="Control/ChangeColorButton" method="RandomizeEventResource"]
|
||||
[connection signal="EventRaisedWithPayload" from="Control/TestLabel" to="Control/TestLabel" method="set_text"]
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
@@ -23,6 +22,26 @@ public partial class EventListener : Node
|
||||
/// The signal that is triggered when this listener is called by one of the <see cref="EventListener._eventResources"/>.
|
||||
/// </summary>
|
||||
[Signal] public delegate void EventRaisedEventHandler();
|
||||
|
||||
/// <summary>
|
||||
/// The signal that is triggered when this listener is called by one of the <see cref="EventListener._eventResources"/>.
|
||||
/// </summary>
|
||||
[Signal] public delegate void EventRaisedWithPayloadEventHandler(Variant payload);
|
||||
|
||||
/// <summary>
|
||||
/// A signal that is triggered when the payload of one of the <see cref="EventListener._eventResources"/> changed.
|
||||
/// </summary>
|
||||
[Signal] public delegate void PayloadChangedEventHandler(Variant payload, Variant oldPayload);
|
||||
|
||||
/// <summary>
|
||||
/// A signal that is triggered when the payload of one of the <see cref="EventListener._eventResources"/> changed.
|
||||
/// </summary>
|
||||
[Signal] public delegate void NewEventPayloadEventHandler(Variant payload);
|
||||
|
||||
/// <summary>
|
||||
/// A signal that is triggered when the payload of one of the <see cref="EventListener._eventResources"/> changed.
|
||||
/// </summary>
|
||||
[Signal] public delegate void OldEventPayloadEventHandler(Variant oldPayload);
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -53,10 +72,24 @@ public partial class EventListener : Node
|
||||
/// Called by a <see cref="EventResource"/>s from the <see cref="_eventResources"/> array.
|
||||
/// Propagates the event by emitting <see cref="EventRaised"/> signal.
|
||||
/// </summary>
|
||||
public void Invoke()
|
||||
public void EventInvoked(Variant payload)
|
||||
{
|
||||
if(_showLog)
|
||||
GD.Print("Event Raised on: " + Name);
|
||||
EmitSignal(SignalName.EventRaised);
|
||||
EmitSignal(SignalName.EventRaisedWithPayload, payload);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by a <see cref="EventResource"/>s from the <see cref="_eventResources"/> array.
|
||||
/// Propagates the event by emitting <see cref="EventRaised"/> signal.
|
||||
/// </summary>
|
||||
public void EventPayloadChanged(Variant payload, Variant oldPayload)
|
||||
{
|
||||
if(_showLog)
|
||||
GD.Print($"Calling Event Payload Changed Signals on: " + Name);
|
||||
EmitSignal(SignalName.PayloadChanged, payload, oldPayload);
|
||||
EmitSignal(SignalName.NewEventPayload, payload);
|
||||
EmitSignal(SignalName.OldEventPayload, oldPayload);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,24 @@ public partial class EventResource : Resource
|
||||
/// Log into console when this event resource is adding or removing listeners, and when it's raised.
|
||||
/// </summary>
|
||||
[Export] private bool _showLog;
|
||||
|
||||
[Export]
|
||||
public Variant Payload
|
||||
{
|
||||
get { return _payload; }
|
||||
set
|
||||
{
|
||||
if (!_payload.Equals(value))
|
||||
{
|
||||
_lastPayload = _payload;
|
||||
_payload = value;
|
||||
ValueChangeHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Variant _payload;
|
||||
private Variant _lastPayload;
|
||||
|
||||
/// <summary>
|
||||
/// Raise-Button Call with Editor Export for easier debugging.
|
||||
@@ -56,7 +74,22 @@ public partial class EventResource : Resource
|
||||
|
||||
foreach (var eventListener in _eventListeners)
|
||||
{
|
||||
eventListener.Invoke();
|
||||
eventListener.EventInvoked(_payload);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the Payload value changed.
|
||||
/// </summary>
|
||||
public void ValueChangeHandler()
|
||||
{
|
||||
if(_showLog)
|
||||
GD.Print($"Event payload changed from {_lastPayload} to {_payload} on event resource: " + ResourcePath.GetFile().TrimSuffix(".tres"));
|
||||
|
||||
foreach (var eventListener in _eventListeners)
|
||||
{
|
||||
eventListener.EventPayloadChanged(_payload, _lastPayload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using Babushka.scripts.CSharp.Low_Code.Events;
|
||||
using Godot;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Low_Code.Randomizer;
|
||||
|
||||
/// <summary>
|
||||
/// A class to randomize the payload value of select types of <see cref="EventResource"/>s.
|
||||
/// </summary>
|
||||
public partial class VariantRandomizer : Node
|
||||
{
|
||||
/// <summary>
|
||||
/// The event resource to work on.
|
||||
/// </summary>
|
||||
[Export] public EventResource _eventResource;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the payload of a randomizable event resource to a random value.
|
||||
/// </summary>
|
||||
public void RandomizeEventResource()
|
||||
{
|
||||
switch (_eventResource.Payload.VariantType)
|
||||
{
|
||||
case Variant.Type.Color:
|
||||
_eventResource.Payload= GetRandomColor();
|
||||
break;
|
||||
case Variant.Type.Int:
|
||||
_eventResource.Payload= GetRandomInt();
|
||||
break;
|
||||
case Variant.Type.Float:
|
||||
_eventResource.Payload= GetRandomFloat();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Color GetRandomColor()
|
||||
{
|
||||
Random rand = new Random();
|
||||
return new Color(rand.NextSingle(), rand.NextSingle(), rand.NextSingle(), 1.0f);
|
||||
}
|
||||
|
||||
private int GetRandomInt()
|
||||
{
|
||||
Random rand = new Random();
|
||||
return rand.Next();
|
||||
}
|
||||
|
||||
private float GetRandomFloat()
|
||||
{
|
||||
Random rand = new Random();
|
||||
return rand.NextSingle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://co1b320qemg1i
|
||||
Reference in New Issue
Block a user