Skip to content

Commit

Permalink
Merge pull request #40 from TaloDev/flush-events-button
Browse files Browse the repository at this point in the history
Add flush events button in playground
  • Loading branch information
tudddorrr authored Oct 25, 2024
2 parents e061665 + b52fed1 commit f0431ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
9 changes: 8 additions & 1 deletion addons/talo/samples/playground/playground.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=24 format=3 uid="uid://bg71kho7jirad"]
[gd_scene load_steps=25 format=3 uid="uid://bg71kho7jirad"]

[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/identify_button.gd" id="1_o53s3"]
[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/identified_state.gd" id="1_qsdrr"]
Expand All @@ -15,6 +15,7 @@
[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/get_saves_button.gd" id="8_4usai"]
[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/get_entries_button.gd" id="8_8262a"]
[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/add_entry_button.gd" id="9_3705v"]
[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/flush_events_button.gd" id="11_ocslk"]
[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/create_save_button.gd" id="12_4prkt"]
[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/loadable_color_rect.gd" id="12_72qp7"]
[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/randomise_save_button.gd" id="12_sshwt"]
Expand Down Expand Up @@ -143,6 +144,11 @@ layout_mode = 2
text = "Track event"
script = ExtResource("4_vboi8")

[node name="FlushEventsButton" type="Button" parent="UI/Content/APIs/Events"]
layout_mode = 2
text = "Flush events"
script = ExtResource("11_ocslk")

[node name="Live config" type="VBoxContainer" parent="UI/Content/APIs"]
layout_mode = 2
theme_override_constants/separation = 20
Expand Down Expand Up @@ -471,6 +477,7 @@ script = ExtResource("19_2r4rn")
[connection signal="pressed" from="UI/Content/APIs/Players_Continuity/Continuity/ToggleContinuityButton" to="UI/Content/APIs/Players_Continuity/Continuity/ToggleContinuityButton" method="_on_pressed"]
[connection signal="pressed" from="UI/Content/APIs/Players_Continuity/Continuity/ToggleNetworkButton" to="UI/Content/APIs/Players_Continuity/Continuity/ToggleNetworkButton" method="_on_pressed"]
[connection signal="pressed" from="UI/Content/APIs/Events/TrackEventButton" to="UI/Content/APIs/Events/TrackEventButton" method="_on_pressed"]
[connection signal="pressed" from="UI/Content/APIs/Events/FlushEventsButton" to="UI/Content/APIs/Events/FlushEventsButton" method="_on_pressed"]
[connection signal="pressed" from="UI/Content/APIs/Live config/GetConfigButton" to="UI/Content/APIs/Live config/GetConfigButton" method="_on_pressed"]
[connection signal="pressed" from="UI/Content/APIs/Stats/TrackStatButton" to="UI/Content/APIs/Stats/TrackStatButton" method="_on_pressed"]
[connection signal="pressed" from="UI/Content/APIs/Leaderboards/GetEntriesButton" to="UI/Content/APIs/Leaderboards/GetEntriesButton" method="_on_pressed"]
Expand Down
9 changes: 9 additions & 0 deletions addons/talo/samples/playground/scripts/flush_events_button.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends Node

func _on_pressed() -> void:
if Talo.identity_check() != OK:
%ResponseLabel.text = "You need to identify a player first!"
return

await Talo.events.flush()
%ResponseLabel.text = "Events flushed"
7 changes: 6 additions & 1 deletion addons/talo/samples/playground/scripts/track_event_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extends Button
@export var event_props: Dictionary = {
"prop1": "value1"
}
@export var flush_immediately: bool

func _on_pressed() -> void:
if Talo.identity_check() != OK:
Expand All @@ -15,4 +16,8 @@ func _on_pressed() -> void:
return

Talo.events.track(event_name, event_props)
%ResponseLabel.text = "Event queued: %s %s" % [event_name, event_props]
if flush_immediately:
await Talo.events.flush()
%ResponseLabel.text = "Event flushed: %s %s" % [event_name, event_props]
else:
%ResponseLabel.text = "Event queued: %s %s" % [event_name, event_props]

0 comments on commit f0431ad

Please sign in to comment.