diff --git a/addons/talo/apis/api.gd b/addons/talo/apis/api.gd index 0cce333..b4f0905 100644 --- a/addons/talo/apis/api.gd +++ b/addons/talo/apis/api.gd @@ -3,6 +3,6 @@ class_name TaloAPI extends Node var client: TaloClient func _init(base_path: String): - name = "Talo%s" % [base_path] + name = "Talo%s" % base_path client = TaloClient.new(base_path) add_child(client) diff --git a/addons/talo/apis/feedback_api.gd b/addons/talo/apis/feedback_api.gd index 41cd3f1..6428e8c 100644 --- a/addons/talo/apis/feedback_api.gd +++ b/addons/talo/apis/feedback_api.gd @@ -10,10 +10,10 @@ func get_categories() -> Array: _: return [] -func send(internal_name: String, comment: String) -> void: +func send(category_internal_name: String, comment: String) -> void: if Talo.identity_check() != OK: return - await client.make_request(HTTPClient.METHOD_POST, "/categories/%s" % internal_name, { + await client.make_request(HTTPClient.METHOD_POST, "/categories/%s" % category_internal_name, { comment = comment }) diff --git a/addons/talo/apis/player_groups_api.gd b/addons/talo/apis/player_groups_api.gd index be72a9c..e067a35 100644 --- a/addons/talo/apis/player_groups_api.gd +++ b/addons/talo/apis/player_groups_api.gd @@ -1,7 +1,7 @@ class_name PlayerGroupsAPI extends TaloAPI func get_group(group_id: String) -> TaloPlayerGroup: - var res = await client.make_request(HTTPClient.METHOD_GET, "/%s" % [group_id]) + var res = await client.make_request(HTTPClient.METHOD_GET, "/%s" % group_id) match (res.status): 200: diff --git a/addons/talo/apis/players_api.gd b/addons/talo/apis/players_api.gd index f57b554..950a409 100644 --- a/addons/talo/apis/players_api.gd +++ b/addons/talo/apis/players_api.gd @@ -34,3 +34,9 @@ func merge(player_id1: String, player_id2: String) -> TaloPlayer: return TaloPlayer.new(res.body.player) _: return null + +func generate_identifer() -> String: + var time_hash: String = String(TimeUtils.get_current_time_msec()).sha256_text() + var size = 12 + var split_start: int = RandomNumberGenerator.new().randi_range(0, time_hash.length() - size) + return time_hash.substr(split_start, size) diff --git a/addons/talo/apis/saves_api.gd b/addons/talo/apis/saves_api.gd index ca248ee..a0803ba 100644 --- a/addons/talo/apis/saves_api.gd +++ b/addons/talo/apis/saves_api.gd @@ -135,7 +135,7 @@ func update_save(save: TaloGameSave, new_name: String = "") -> TaloGameSave: if Talo.identity_check() != OK: return - var res = await client.make_request(HTTPClient.METHOD_PATCH, "/%s" % [save.id], { + var res = await client.make_request(HTTPClient.METHOD_PATCH, "/%s" % save.id, { name=save.display_name if new_name.is_empty() else new_name, content=content }) @@ -152,7 +152,7 @@ func delete_save(save: TaloGameSave) -> void: if Talo.identity_check() != OK: return - var res = await client.make_request(HTTPClient.METHOD_DELETE, "/%s" % [save.id]) + var res = await client.make_request(HTTPClient.METHOD_DELETE, "/%s" % save.id) match res.status: _: diff --git a/addons/talo/plugin.cfg b/addons/talo/plugin.cfg index 9767ffa..f454e45 100644 --- a/addons/talo/plugin.cfg +++ b/addons/talo/plugin.cfg @@ -3,5 +3,5 @@ name="Talo Game Services" description="Talo (https://trytalo.com) is an open-source game backend with services designed to help you build games faster. You can currently:\n\n- Identify and authenticate players\n- Store persistent data across players\n- Track events (levelling up, finding loot, etc)\n- Display high scores with leaderboards\n- Store and load player saves\n- Load game config options and flags from the cloud\n- Get feedback directly from your players" author="trytalo" -version="0.11.0" +version="0.12.0" script="talo_autoload.gd" diff --git a/addons/talo/samples/authentication/scripts/in_game.gd b/addons/talo/samples/authentication/scripts/in_game.gd index fdd86cf..0ff91a7 100644 --- a/addons/talo/samples/authentication/scripts/in_game.gd +++ b/addons/talo/samples/authentication/scripts/in_game.gd @@ -11,7 +11,7 @@ func _ready() -> void: Talo.players.identified.connect(_on_player_identified) func _on_player_identified(player: TaloPlayer) -> void: - username.text = "What would you like to do,\n%s?" % [Talo.current_alias.identifier] + username.text = "What would you like to do,\n%s?" % Talo.current_alias.identifier func _on_change_password_pressed() -> void: go_to_change_password.emit() diff --git a/addons/talo/samples/leaderboards/scripts/leaderboard.gd b/addons/talo/samples/leaderboards/scripts/leaderboard.gd index 96c4f84..6fc77d7 100644 --- a/addons/talo/samples/leaderboards/scripts/leaderboard.gd +++ b/addons/talo/samples/leaderboards/scripts/leaderboard.gd @@ -21,11 +21,11 @@ func _ready() -> void: func _set_entry_count(): if entries_container.get_child_count() == 0: - info_label.text = "No entries yet!" if not _entries_error else "Failed loading leaderboard %s. Does it exist?" % [leaderboard_internal_name] + info_label.text = "No entries yet!" if not _entries_error else "Failed loading leaderboard %s. Does it exist?" % leaderboard_internal_name else: - info_label.text = "%s entries" % [entries_container.get_child_count()] + info_label.text = "%s entries" % entries_container.get_child_count() if _filter != "All": - info_label.text += " (%s team)" % [_filter] + info_label.text += " (%s team)" % _filter func _create_entry(entry: TaloLeaderboardEntry) -> void: var entry_instance = entry_scene.instantiate() @@ -82,7 +82,7 @@ func _on_filter_pressed() -> void: _filter_idx += 1 _filter = _get_next_filter(_filter_idx) - info_label.text = "Filtering on %s" % [filter_button.text.to_lower()] - filter_button.text = "%s team scores" % [_get_next_filter(_filter_idx + 1)] + info_label.text = "Filtering on %s" % filter_button.text.to_lower() + filter_button.text = "%s team scores" % _get_next_filter(_filter_idx + 1) _build_entries() diff --git a/addons/talo/samples/leaderboards/scripts/leaderboard_entry.gd b/addons/talo/samples/leaderboards/scripts/leaderboard_entry.gd index fafd7c0..dcfdf12 100644 --- a/addons/talo/samples/leaderboards/scripts/leaderboard_entry.gd +++ b/addons/talo/samples/leaderboards/scripts/leaderboard_entry.gd @@ -11,7 +11,7 @@ func _set_score(score: int) -> void: func _set_team(team: String) -> void: if not team.is_empty(): - text += " (%s team)" % [team] + text += " (%s team)" % team func set_data(entry: TaloLeaderboardEntry) -> void: _set_pos(entry.position) diff --git a/addons/talo/samples/playground/playground.tscn b/addons/talo/samples/playground/playground.tscn index f1513fd..590a4e4 100644 --- a/addons/talo/samples/playground/playground.tscn +++ b/addons/talo/samples/playground/playground.tscn @@ -1,20 +1,21 @@ -[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"] [ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/identified_label.gd" id="2_ncaxm"] [ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/response_label.gd" id="3_bdtqj"] -[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/level_up_button.gd" id="4_vboi8"] +[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/track_event_button.gd" id="4_vboi8"] [ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/get_config_button.gd" id="5_blrul"] -[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/set_health_button.gd" id="5_fpvjp"] -[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/discover_secret_button.gd" id="5_wpnvd"] -[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/delete_health_button.gd" id="6_it1yx"] +[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/set_prop_button.gd" id="5_fpvjp"] +[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/track_stat_button.gd" id="5_wpnvd"] +[ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/delete_prop_button.gd" id="6_it1yx"] [ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/toggle_continuity_button.gd" id="6_pvyh2"] [ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/get_group_button.gd" id="7_5qx11"] [ext_resource type="Script" path="res://addons/talo/samples/playground/scripts/toggle_network_button.gd" id="7_wsc44"] [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"] @@ -39,10 +40,10 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -color = Color(0.980392, 0.392157, 0.470588, 1) +color = Color(1, 0.509804, 0.627451, 1) script = ExtResource("1_qsdrr") -[node name="MarginContainer" type="MarginContainer" parent="UI"] +[node name="Content" type="MarginContainer" parent="UI"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -54,7 +55,7 @@ theme_override_constants/margin_top = 40 theme_override_constants/margin_right = 40 theme_override_constants/margin_bottom = 40 -[node name="IdentifiedLabel" type="Label" parent="UI/MarginContainer"] +[node name="IdentifiedLabel" type="Label" parent="UI/Content"] layout_mode = 2 size_flags_horizontal = 8 size_flags_vertical = 8 @@ -62,181 +63,182 @@ theme_override_colors/font_color = Color(0, 0, 0, 1) text = "Player not identified" script = ExtResource("2_ncaxm") -[node name="ResponseLabel" type="Label" parent="UI/MarginContainer"] +[node name="ResponseLabel" type="Label" parent="UI/Content"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 size_flags_vertical = 8 theme_override_colors/font_color = Color(0, 0, 0, 1) script = ExtResource("3_bdtqj") -[node name="APIs" type="HBoxContainer" parent="UI/MarginContainer"] +[node name="APIs" type="HBoxContainer" parent="UI/Content"] layout_mode = 2 theme_override_constants/separation = 40 -[node name="Players_Continuity" type="VBoxContainer" parent="UI/MarginContainer/APIs"] +[node name="Players_Continuity" type="VBoxContainer" parent="UI/Content/APIs"] layout_mode = 2 theme_override_constants/separation = 40 -[node name="Players" type="VBoxContainer" parent="UI/MarginContainer/APIs/Players_Continuity"] +[node name="Players" type="VBoxContainer" parent="UI/Content/APIs/Players_Continuity"] layout_mode = 2 theme_override_constants/separation = 20 -[node name="Label" type="Label" parent="UI/MarginContainer/APIs/Players_Continuity/Players"] +[node name="Label" type="Label" parent="UI/Content/APIs/Players_Continuity/Players"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 20 text = "Players" -[node name="IdentifyButton" type="Button" parent="UI/MarginContainer/APIs/Players_Continuity/Players"] +[node name="IdentifyButton" type="Button" parent="UI/Content/APIs/Players_Continuity/Players"] layout_mode = 2 text = "Identify" script = ExtResource("1_o53s3") -service = "username" -identifier = "TaloPlayer" -[node name="SetHealthButton" type="Button" parent="UI/MarginContainer/APIs/Players_Continuity/Players"] +[node name="SetPropButton" type="Button" parent="UI/Content/APIs/Players_Continuity/Players"] layout_mode = 2 -text = "Set health" +text = "Set prop" script = ExtResource("5_fpvjp") -[node name="DeleteHealthButton" type="Button" parent="UI/MarginContainer/APIs/Players_Continuity/Players"] +[node name="DeletePropButton" type="Button" parent="UI/Content/APIs/Players_Continuity/Players"] layout_mode = 2 -text = "Delete health" +text = "Delete prop" script = ExtResource("6_it1yx") -[node name="GetGroupButton" type="Button" parent="UI/MarginContainer/APIs/Players_Continuity/Players"] +[node name="GetGroupButton" type="Button" parent="UI/Content/APIs/Players_Continuity/Players"] layout_mode = 2 text = "Get group" script = ExtResource("7_5qx11") -[node name="Continuity" type="VBoxContainer" parent="UI/MarginContainer/APIs/Players_Continuity"] +[node name="Continuity" type="VBoxContainer" parent="UI/Content/APIs/Players_Continuity"] layout_mode = 2 theme_override_constants/separation = 20 -[node name="Label" type="Label" parent="UI/MarginContainer/APIs/Players_Continuity/Continuity"] +[node name="Label" type="Label" parent="UI/Content/APIs/Players_Continuity/Continuity"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 20 text = "Continuity" -[node name="ToggleContinuityButton" type="Button" parent="UI/MarginContainer/APIs/Players_Continuity/Continuity"] +[node name="ToggleContinuityButton" type="Button" parent="UI/Content/APIs/Players_Continuity/Continuity"] layout_mode = 2 text = "Toggle" script = ExtResource("6_pvyh2") -[node name="ToggleNetworkButton" type="Button" parent="UI/MarginContainer/APIs/Players_Continuity/Continuity"] +[node name="ToggleNetworkButton" type="Button" parent="UI/Content/APIs/Players_Continuity/Continuity"] layout_mode = 2 text = "Go offline" script = ExtResource("7_wsc44") -[node name="Events" type="VBoxContainer" parent="UI/MarginContainer/APIs"] +[node name="Events" type="VBoxContainer" parent="UI/Content/APIs"] layout_mode = 2 theme_override_constants/separation = 20 -[node name="Label" type="Label" parent="UI/MarginContainer/APIs/Events"] +[node name="Label" type="Label" parent="UI/Content/APIs/Events"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 20 text = "Events" -[node name="LevelUpButton" type="Button" parent="UI/MarginContainer/APIs/Events"] +[node name="TrackEventButton" type="Button" parent="UI/Content/APIs/Events"] layout_mode = 2 -text = "Level up" +text = "Track event" script = ExtResource("4_vboi8") -[node name="Live config" type="VBoxContainer" parent="UI/MarginContainer/APIs"] +[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 -[node name="Label" type="Label" parent="UI/MarginContainer/APIs/Live config"] +[node name="Label" type="Label" parent="UI/Content/APIs/Live config"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 20 text = "Live config" -[node name="GetConfigButton" type="Button" parent="UI/MarginContainer/APIs/Live config"] +[node name="GetConfigButton" type="Button" parent="UI/Content/APIs/Live config"] layout_mode = 2 text = "Get config" script = ExtResource("5_blrul") -[node name="Stats" type="VBoxContainer" parent="UI/MarginContainer/APIs"] +[node name="Stats" type="VBoxContainer" parent="UI/Content/APIs"] layout_mode = 2 theme_override_constants/separation = 20 -[node name="Label" type="Label" parent="UI/MarginContainer/APIs/Stats"] +[node name="Label" type="Label" parent="UI/Content/APIs/Stats"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 20 text = "Stats" -[node name="DiscoverSecretButton" type="Button" parent="UI/MarginContainer/APIs/Stats"] +[node name="TrackStatButton" type="Button" parent="UI/Content/APIs/Stats"] layout_mode = 2 -text = "Discover secret" +text = "Track stat" script = ExtResource("5_wpnvd") -stat_name = "secrets-discovered" -[node name="Leaderboards" type="VBoxContainer" parent="UI/MarginContainer/APIs"] +[node name="Leaderboards" type="VBoxContainer" parent="UI/Content/APIs"] layout_mode = 2 theme_override_constants/separation = 20 -[node name="Label" type="Label" parent="UI/MarginContainer/APIs/Leaderboards"] +[node name="Label" type="Label" parent="UI/Content/APIs/Leaderboards"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 20 text = "Leaderboards" -[node name="GetEntriesButton" type="Button" parent="UI/MarginContainer/APIs/Leaderboards"] +[node name="GetEntriesButton" type="Button" parent="UI/Content/APIs/Leaderboards"] layout_mode = 2 text = "Get entries" script = ExtResource("8_8262a") -leaderboard_name = "sed-totam-magni" -[node name="AddEntryButton" type="Button" parent="UI/MarginContainer/APIs/Leaderboards"] +[node name="AddEntryButton" type="Button" parent="UI/Content/APIs/Leaderboards"] layout_mode = 2 text = "Add entry" script = ExtResource("9_3705v") -leaderboard_name = "sed-totam-magni" -[node name="Saves" type="VBoxContainer" parent="UI/MarginContainer/APIs"] +[node name="Saves" type="VBoxContainer" parent="UI/Content/APIs"] layout_mode = 2 theme_override_constants/separation = 20 -[node name="Label" type="Label" parent="UI/MarginContainer/APIs/Saves"] +[node name="Label" type="Label" parent="UI/Content/APIs/Saves"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 20 text = "Saves" -[node name="GetSavesButton" type="Button" parent="UI/MarginContainer/APIs/Saves"] +[node name="GetSavesButton" type="Button" parent="UI/Content/APIs/Saves"] layout_mode = 2 text = "Get saves" script = ExtResource("8_4usai") -[node name="LoadSaveButton" type="Button" parent="UI/MarginContainer/APIs/Saves"] +[node name="LoadSaveButton" type="Button" parent="UI/Content/APIs/Saves"] layout_mode = 2 text = "Load save" script = ExtResource("12_t2845") -[node name="CreateSaveButton" type="Button" parent="UI/MarginContainer/APIs/Saves"] +[node name="CreateSaveButton" type="Button" parent="UI/Content/APIs/Saves"] layout_mode = 2 text = "Create save" script = ExtResource("12_4prkt") -[node name="UpdateSaveButton" type="Button" parent="UI/MarginContainer/APIs/Saves"] +[node name="UpdateSaveButton" type="Button" parent="UI/Content/APIs/Saves"] layout_mode = 2 text = "Update save" script = ExtResource("14_lvmju") -[node name="DeleteSaveButton" type="Button" parent="UI/MarginContainer/APIs/Saves"] +[node name="DeleteSaveButton" type="Button" parent="UI/Content/APIs/Saves"] layout_mode = 2 text = "Delete save" script = ExtResource("15_iq1bk") -[node name="VBoxContainer" type="VBoxContainer" parent="UI/MarginContainer/APIs/Saves"] +[node name="VBoxContainer" type="VBoxContainer" parent="UI/Content/APIs/Saves"] layout_mode = 2 theme_override_constants/separation = 8 -[node name="Label" type="Label" parent="UI/MarginContainer/APIs/Saves/VBoxContainer"] +[node name="Label" type="Label" parent="UI/Content/APIs/Saves/VBoxContainer"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_constants/line_spacing = -4 @@ -245,7 +247,7 @@ text = "Current save" horizontal_alignment = 1 uppercase = true -[node name="GridContainer" type="GridContainer" parent="UI/MarginContainer/APIs/Saves/VBoxContainer"] +[node name="GridContainer" type="GridContainer" parent="UI/Content/APIs/Saves/VBoxContainer"] layout_mode = 2 size_flags_horizontal = 6 size_flags_vertical = 4 @@ -253,13 +255,13 @@ theme_override_constants/h_separation = 8 theme_override_constants/v_separation = 8 columns = 3 -[node name="Control" type="Control" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer"] +[node name="Control" type="Control" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(16, 16) layout_mode = 2 script = ExtResource("12_72qp7") id = "CR1" -[node name="BG" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control"] +[node name="BG" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control"] custom_minimum_size = Vector2(18, 18) layout_mode = 0 offset_left = -1.0 @@ -268,19 +270,19 @@ offset_right = 17.0 offset_bottom = 17.0 color = Color(0, 0, 0, 1) -[node name="ColorRect" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control"] +[node name="ColorRect" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control"] custom_minimum_size = Vector2(16, 16) layout_mode = 0 offset_right = 16.0 offset_bottom = 16.0 -[node name="Control2" type="Control" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer"] +[node name="Control2" type="Control" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(16, 16) layout_mode = 2 script = ExtResource("12_72qp7") id = "CR2" -[node name="BG" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control2"] +[node name="BG" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control2"] custom_minimum_size = Vector2(18, 18) layout_mode = 0 offset_left = -1.0 @@ -289,19 +291,19 @@ offset_right = 17.0 offset_bottom = 17.0 color = Color(0, 0, 0, 1) -[node name="ColorRect" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control2"] +[node name="ColorRect" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control2"] custom_minimum_size = Vector2(16, 16) layout_mode = 0 offset_right = 16.0 offset_bottom = 16.0 -[node name="Control3" type="Control" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer"] +[node name="Control3" type="Control" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(16, 16) layout_mode = 2 script = ExtResource("12_72qp7") id = "CR3" -[node name="BG" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control3"] +[node name="BG" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control3"] custom_minimum_size = Vector2(18, 18) layout_mode = 0 offset_left = -1.0 @@ -310,19 +312,19 @@ offset_right = 17.0 offset_bottom = 17.0 color = Color(0, 0, 0, 1) -[node name="ColorRect" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control3"] +[node name="ColorRect" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control3"] custom_minimum_size = Vector2(16, 16) layout_mode = 0 offset_right = 16.0 offset_bottom = 16.0 -[node name="Control4" type="Control" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer"] +[node name="Control4" type="Control" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(16, 16) layout_mode = 2 script = ExtResource("12_72qp7") id = "CR4" -[node name="BG" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control4"] +[node name="BG" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control4"] custom_minimum_size = Vector2(18, 18) layout_mode = 0 offset_left = -1.0 @@ -331,19 +333,19 @@ offset_right = 17.0 offset_bottom = 17.0 color = Color(0, 0, 0, 1) -[node name="ColorRect" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control4"] +[node name="ColorRect" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control4"] custom_minimum_size = Vector2(16, 16) layout_mode = 0 offset_right = 16.0 offset_bottom = 16.0 -[node name="Control5" type="Control" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer"] +[node name="Control5" type="Control" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(16, 16) layout_mode = 2 script = ExtResource("12_72qp7") id = "CR5" -[node name="BG" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control5"] +[node name="BG" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control5"] custom_minimum_size = Vector2(18, 18) layout_mode = 0 offset_left = -1.0 @@ -352,19 +354,19 @@ offset_right = 17.0 offset_bottom = 17.0 color = Color(0, 0, 0, 1) -[node name="ColorRect" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control5"] +[node name="ColorRect" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control5"] custom_minimum_size = Vector2(16, 16) layout_mode = 0 offset_right = 16.0 offset_bottom = 16.0 -[node name="Control6" type="Control" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer"] +[node name="Control6" type="Control" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(16, 16) layout_mode = 2 script = ExtResource("12_72qp7") id = "CR6" -[node name="BG" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control6"] +[node name="BG" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control6"] custom_minimum_size = Vector2(18, 18) layout_mode = 0 offset_left = -1.0 @@ -373,19 +375,19 @@ offset_right = 17.0 offset_bottom = 17.0 color = Color(0, 0, 0, 1) -[node name="ColorRect" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control6"] +[node name="ColorRect" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control6"] custom_minimum_size = Vector2(16, 16) layout_mode = 0 offset_right = 16.0 offset_bottom = 16.0 -[node name="Control7" type="Control" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer"] +[node name="Control7" type="Control" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(16, 16) layout_mode = 2 script = ExtResource("12_72qp7") id = "CR7" -[node name="BG" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control7"] +[node name="BG" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control7"] custom_minimum_size = Vector2(18, 18) layout_mode = 0 offset_left = -1.0 @@ -394,19 +396,19 @@ offset_right = 17.0 offset_bottom = 17.0 color = Color(0, 0, 0, 1) -[node name="ColorRect" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control7"] +[node name="ColorRect" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control7"] custom_minimum_size = Vector2(16, 16) layout_mode = 0 offset_right = 16.0 offset_bottom = 16.0 -[node name="Control8" type="Control" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer"] +[node name="Control8" type="Control" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(16, 16) layout_mode = 2 script = ExtResource("12_72qp7") id = "CR8" -[node name="BG" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control8"] +[node name="BG" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control8"] custom_minimum_size = Vector2(18, 18) layout_mode = 0 offset_left = -1.0 @@ -415,19 +417,19 @@ offset_right = 17.0 offset_bottom = 17.0 color = Color(0, 0, 0, 1) -[node name="ColorRect" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control8"] +[node name="ColorRect" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control8"] custom_minimum_size = Vector2(16, 16) layout_mode = 0 offset_right = 16.0 offset_bottom = 16.0 -[node name="Control9" type="Control" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer"] +[node name="Control9" type="Control" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(16, 16) layout_mode = 2 script = ExtResource("12_72qp7") id = "CR9" -[node name="BG" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control9"] +[node name="BG" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control9"] custom_minimum_size = Vector2(18, 18) layout_mode = 0 offset_left = -1.0 @@ -436,56 +438,55 @@ offset_right = 17.0 offset_bottom = 17.0 color = Color(0, 0, 0, 1) -[node name="ColorRect" type="ColorRect" parent="UI/MarginContainer/APIs/Saves/VBoxContainer/GridContainer/Control9"] +[node name="ColorRect" type="ColorRect" parent="UI/Content/APIs/Saves/VBoxContainer/GridContainer/Control9"] custom_minimum_size = Vector2(16, 16) layout_mode = 0 offset_right = 16.0 offset_bottom = 16.0 -[node name="RandomiseSaveButton" type="Button" parent="UI/MarginContainer/APIs/Saves/VBoxContainer" node_paths=PackedStringArray("grid")] +[node name="RandomiseSaveButton" type="Button" parent="UI/Content/APIs/Saves/VBoxContainer" node_paths=PackedStringArray("grid")] layout_mode = 2 text = "Randomise" script = ExtResource("12_sshwt") grid = NodePath("../GridContainer") -[node name="Feedback" type="VBoxContainer" parent="UI/MarginContainer/APIs"] +[node name="Feedback" type="VBoxContainer" parent="UI/Content/APIs"] layout_mode = 2 theme_override_constants/separation = 20 -[node name="Label" type="Label" parent="UI/MarginContainer/APIs/Feedback"] +[node name="Label" type="Label" parent="UI/Content/APIs/Feedback"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 20 text = "Feedback" -[node name="GetCategoriesButton" type="Button" parent="UI/MarginContainer/APIs/Feedback"] +[node name="GetCategoriesButton" type="Button" parent="UI/Content/APIs/Feedback"] layout_mode = 2 text = "Get categories" script = ExtResource("18_vdjyg") -[node name="SendFeedbackButton" type="Button" parent="UI/MarginContainer/APIs/Feedback"] +[node name="SendFeedbackButton" type="Button" parent="UI/Content/APIs/Feedback"] layout_mode = 2 text = "Send feedback" script = ExtResource("19_2r4rn") -internal_name = "bugs" -feedback_comment = "There is a bug in the game somewhere, go find it" - -[connection signal="pressed" from="UI/MarginContainer/APIs/Players_Continuity/Players/IdentifyButton" to="UI/MarginContainer/APIs/Players_Continuity/Players/IdentifyButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Players_Continuity/Players/SetHealthButton" to="UI/MarginContainer/APIs/Players_Continuity/Players/SetHealthButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Players_Continuity/Players/DeleteHealthButton" to="UI/MarginContainer/APIs/Players_Continuity/Players/DeleteHealthButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Players_Continuity/Players/GetGroupButton" to="UI/MarginContainer/APIs/Players_Continuity/Players/GetGroupButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Players_Continuity/Continuity/ToggleContinuityButton" to="UI/MarginContainer/APIs/Players_Continuity/Continuity/ToggleContinuityButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Players_Continuity/Continuity/ToggleNetworkButton" to="UI/MarginContainer/APIs/Players_Continuity/Continuity/ToggleNetworkButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Events/LevelUpButton" to="UI/MarginContainer/APIs/Events/LevelUpButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Live config/GetConfigButton" to="UI/MarginContainer/APIs/Live config/GetConfigButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Stats/DiscoverSecretButton" to="UI/MarginContainer/APIs/Stats/DiscoverSecretButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Leaderboards/GetEntriesButton" to="UI/MarginContainer/APIs/Leaderboards/GetEntriesButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Leaderboards/AddEntryButton" to="UI/MarginContainer/APIs/Leaderboards/AddEntryButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Saves/GetSavesButton" to="UI/MarginContainer/APIs/Saves/GetSavesButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Saves/LoadSaveButton" to="UI/MarginContainer/APIs/Saves/LoadSaveButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Saves/CreateSaveButton" to="UI/MarginContainer/APIs/Saves/CreateSaveButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Saves/UpdateSaveButton" to="UI/MarginContainer/APIs/Saves/UpdateSaveButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Saves/DeleteSaveButton" to="UI/MarginContainer/APIs/Saves/DeleteSaveButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Saves/VBoxContainer/RandomiseSaveButton" to="UI/MarginContainer/APIs/Saves/VBoxContainer/RandomiseSaveButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Feedback/GetCategoriesButton" to="UI/MarginContainer/APIs/Feedback/GetCategoriesButton" method="_on_pressed"] -[connection signal="pressed" from="UI/MarginContainer/APIs/Feedback/SendFeedbackButton" to="UI/MarginContainer/APIs/Feedback/SendFeedbackButton" method="_on_pressed"] + +[connection signal="pressed" from="UI/Content/APIs/Players_Continuity/Players/IdentifyButton" to="UI/Content/APIs/Players_Continuity/Players/IdentifyButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Players_Continuity/Players/SetPropButton" to="UI/Content/APIs/Players_Continuity/Players/SetPropButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Players_Continuity/Players/DeletePropButton" to="UI/Content/APIs/Players_Continuity/Players/DeletePropButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Players_Continuity/Players/GetGroupButton" to="UI/Content/APIs/Players_Continuity/Players/GetGroupButton" method="_on_pressed"] +[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"] +[connection signal="pressed" from="UI/Content/APIs/Leaderboards/AddEntryButton" to="UI/Content/APIs/Leaderboards/AddEntryButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Saves/GetSavesButton" to="UI/Content/APIs/Saves/GetSavesButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Saves/LoadSaveButton" to="UI/Content/APIs/Saves/LoadSaveButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Saves/CreateSaveButton" to="UI/Content/APIs/Saves/CreateSaveButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Saves/UpdateSaveButton" to="UI/Content/APIs/Saves/UpdateSaveButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Saves/DeleteSaveButton" to="UI/Content/APIs/Saves/DeleteSaveButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Saves/VBoxContainer/RandomiseSaveButton" to="UI/Content/APIs/Saves/VBoxContainer/RandomiseSaveButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Feedback/GetCategoriesButton" to="UI/Content/APIs/Feedback/GetCategoriesButton" method="_on_pressed"] +[connection signal="pressed" from="UI/Content/APIs/Feedback/SendFeedbackButton" to="UI/Content/APIs/Feedback/SendFeedbackButton" method="_on_pressed"] diff --git a/addons/talo/samples/playground/scripts/add_entry_button.gd b/addons/talo/samples/playground/scripts/add_entry_button.gd index 9c1c153..8529668 100644 --- a/addons/talo/samples/playground/scripts/add_entry_button.gd +++ b/addons/talo/samples/playground/scripts/add_entry_button.gd @@ -1,11 +1,18 @@ extends Button -@onready var response_label: Label = $"/root/Playground/UI/MarginContainer/ResponseLabel" @export var leaderboard_name: String func _on_pressed() -> void: + if Talo.identity_check() != OK: + %ResponseLabel.text = "You need to identify a player first!" + return + + if leaderboard_name.is_empty(): + %ResponseLabel.text = "leaderboard_name not set on AddEntryButton" + return + var score = RandomNumberGenerator.new().randi_range(1, 50) var res = await Talo.leaderboards.add_entry(leaderboard_name, score) if res.size() > 0: - response_label.text = "Added score: %s, new high score: %s" % [score, res[1]] + %ResponseLabel.text = "Added score: %s, new high score: %s" % [score, res[1]] diff --git a/addons/talo/samples/playground/scripts/delete_health_button.gd b/addons/talo/samples/playground/scripts/delete_health_button.gd deleted file mode 100644 index 8632b1d..0000000 --- a/addons/talo/samples/playground/scripts/delete_health_button.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends Button - -func _on_pressed() -> void: - if Talo.identity_check() != OK: - return - - Talo.current_player.delete_prop("health") diff --git a/addons/talo/samples/playground/scripts/delete_prop_button.gd b/addons/talo/samples/playground/scripts/delete_prop_button.gd new file mode 100644 index 0000000..cf0fdd7 --- /dev/null +++ b/addons/talo/samples/playground/scripts/delete_prop_button.gd @@ -0,0 +1,14 @@ +extends Button + +@export var prop_name: String + +func _on_pressed() -> void: + if Talo.identity_check() != OK: + %ResponseLabel.text = "You need to identify a player first!" + return + + if prop_name.is_empty(): + %ResponseLabel.text = "prop_name not set on DeletePropButton" + return + + Talo.current_player.delete_prop(prop_name) diff --git a/addons/talo/samples/playground/scripts/discover_secret_button.gd b/addons/talo/samples/playground/scripts/discover_secret_button.gd deleted file mode 100644 index e3a5b3f..0000000 --- a/addons/talo/samples/playground/scripts/discover_secret_button.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends Button - -@export var stat_name: String - -func _on_pressed() -> void: - Talo.stats.track(stat_name) diff --git a/addons/talo/samples/playground/scripts/flush_events_button.gd b/addons/talo/samples/playground/scripts/flush_events_button.gd new file mode 100644 index 0000000..523202d --- /dev/null +++ b/addons/talo/samples/playground/scripts/flush_events_button.gd @@ -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" diff --git a/addons/talo/samples/playground/scripts/get_categories_button.gd b/addons/talo/samples/playground/scripts/get_categories_button.gd index 8df394d..504f7af 100644 --- a/addons/talo/samples/playground/scripts/get_categories_button.gd +++ b/addons/talo/samples/playground/scripts/get_categories_button.gd @@ -1,12 +1,10 @@ extends Button -@onready var response_label: Label = $"/root/Playground/UI/MarginContainer/ResponseLabel" - func _on_pressed() -> void: var categories = await Talo.feedback.get_categories() if categories.size() == 0: - response_label.text = "No categories found. Create some in the Talo dashboard!" + %ResponseLabel.text = "No categories found. Create some in the Talo dashboard!" else: var mapped = categories.map(func (c): return "%s (%s)" % [c.display_name, c.internal_name]) - response_label.text = "Categories: " + ", ".join(mapped) + %ResponseLabel.text = "Categories: " + ", ".join(mapped) diff --git a/addons/talo/samples/playground/scripts/get_entries_button.gd b/addons/talo/samples/playground/scripts/get_entries_button.gd index 9f74377..cfeb968 100644 --- a/addons/talo/samples/playground/scripts/get_entries_button.gd +++ b/addons/talo/samples/playground/scripts/get_entries_button.gd @@ -1,11 +1,16 @@ extends Button -@onready var response_label: Label = $"/root/Playground/UI/MarginContainer/ResponseLabel" @export var leaderboard_name: String func _on_pressed() -> void: + if leaderboard_name.is_empty(): + %ResponseLabel.text = "leaderboard_name not set on GetEntriesButton" + return + var res = await Talo.leaderboards.get_entries(leaderboard_name, 0) if res.size() > 0: var entries = res[0] - response_label.text = "Received %s entries" % entries.size() + %ResponseLabel.text = "Received %s entries" % entries.size() + else: + %ResponseLabel.text = "No entries found for %s" % leaderboard_name diff --git a/addons/talo/samples/playground/scripts/get_group_button.gd b/addons/talo/samples/playground/scripts/get_group_button.gd index d239464..f6a3eb0 100644 --- a/addons/talo/samples/playground/scripts/get_group_button.gd +++ b/addons/talo/samples/playground/scripts/get_group_button.gd @@ -1,14 +1,14 @@ extends Button -@onready var response_label: Label = $"/root/Playground/UI/MarginContainer/ResponseLabel" -@export var group_id: String = "" +@export var group_id: String func _on_pressed() -> void: - if not group_id.is_empty(): - var group = await Talo.player_groups.get_group(group_id) - if group != null: - response_label.text = "%s has %s player(s)" % [group.display_name, group.count] - else: - print_rich("[color=yellow]Group %s not found[/color]" % [group_id]) + if group_id.is_empty(): + %ResponseLabel.text = "group_id not set on GetGroupButton" + return + + var group = await Talo.player_groups.get_group(group_id) + if group != null: + %ResponseLabel.text = "%s has %s player(s)" % [group.display_name, group.count] else: - print_rich("[color=yellow]group_id not set on GetGroupButton[/color]") + %ResponseLabel.text = "Group %s not found" % group_id diff --git a/addons/talo/samples/playground/scripts/identified_state.gd b/addons/talo/samples/playground/scripts/identified_state.gd index 951b27b..d5ac8ad 100644 --- a/addons/talo/samples/playground/scripts/identified_state.gd +++ b/addons/talo/samples/playground/scripts/identified_state.gd @@ -4,4 +4,4 @@ func _ready() -> void: Talo.players.identified.connect(_on_identified) func _on_identified(_player: TaloPlayer) -> void: - color = Color(0.0, 190.0 / 255.0, 130.0 / 255.0) + color = Color(120.0 / 255.0, 230.0 / 255.0, 160.0 / 255.0) diff --git a/addons/talo/samples/playground/scripts/identify_button.gd b/addons/talo/samples/playground/scripts/identify_button.gd index 1e86027..0987887 100644 --- a/addons/talo/samples/playground/scripts/identify_button.gd +++ b/addons/talo/samples/playground/scripts/identify_button.gd @@ -1,7 +1,11 @@ extends Button -@export var service: String +@export var service: String = "username" @export var identifier: String func _on_pressed(): + if service.is_empty() or identifier.is_empty(): + %ResponseLabel.text = "service or identifier not set on IdentifyButton" + return + Talo.players.identify(service, identifier) diff --git a/addons/talo/samples/playground/scripts/level_up_button.gd b/addons/talo/samples/playground/scripts/level_up_button.gd deleted file mode 100644 index 6d34677..0000000 --- a/addons/talo/samples/playground/scripts/level_up_button.gd +++ /dev/null @@ -1,10 +0,0 @@ -extends Button - -var level = 1 - -func _on_pressed() -> void: - level += 1 - - Talo.events.track("Levelled up", { - "New level": level - }) diff --git a/addons/talo/samples/playground/scripts/send_feedback_button.gd b/addons/talo/samples/playground/scripts/send_feedback_button.gd index 309ea74..f330c70 100644 --- a/addons/talo/samples/playground/scripts/send_feedback_button.gd +++ b/addons/talo/samples/playground/scripts/send_feedback_button.gd @@ -1,10 +1,16 @@ extends Button -@export var internal_name: String -@export var feedback_comment: String - -@onready var response_label: Label = $"/root/Playground/UI/MarginContainer/ResponseLabel" +@export var category_name: String +@export var feedback_comment: String = "There is a bug in the game somewhere, go find it" func _on_pressed() -> void: - await Talo.feedback.send(internal_name, feedback_comment) - response_label.text = "Feedback sent for %s: %s" % [internal_name, feedback_comment] + if Talo.identity_check() != OK: + %ResponseLabel.text = "You need to identify a player first!" + return + + if category_name.is_empty() or feedback_comment.is_empty(): + %ResponseLabel.text = "category_name or feedback_comment not set on SendFeedbackButton" + return + + await Talo.feedback.send(category_name, feedback_comment) + %ResponseLabel.text = "Feedback sent for %s: %s" % [category_name, feedback_comment] diff --git a/addons/talo/samples/playground/scripts/set_health_button.gd b/addons/talo/samples/playground/scripts/set_health_button.gd deleted file mode 100644 index fcd20cf..0000000 --- a/addons/talo/samples/playground/scripts/set_health_button.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends Button - -func _on_pressed() -> void: - if Talo.identity_check() != OK: - return - - Talo.current_player.set_prop("health", str(RandomNumberGenerator.new().randi_range(1, 100))) diff --git a/addons/talo/samples/playground/scripts/set_prop_button.gd b/addons/talo/samples/playground/scripts/set_prop_button.gd new file mode 100644 index 0000000..261ba58 --- /dev/null +++ b/addons/talo/samples/playground/scripts/set_prop_button.gd @@ -0,0 +1,15 @@ +extends Button + +@export var prop_name: String +@export var prop_value: String + +func _on_pressed() -> void: + if Talo.identity_check() != OK: + %ResponseLabel.text = "You need to identify a player first!" + return + + if prop_name.is_empty() or prop_value.is_empty(): + %ResponseLabel.text = "prop_name or prop_value not set on SetPropButton" + return + + Talo.current_player.set_prop(prop_name, prop_value) diff --git a/addons/talo/samples/playground/scripts/toggle_continuity_button.gd b/addons/talo/samples/playground/scripts/toggle_continuity_button.gd index 19c611f..7b051c6 100644 --- a/addons/talo/samples/playground/scripts/toggle_continuity_button.gd +++ b/addons/talo/samples/playground/scripts/toggle_continuity_button.gd @@ -1,7 +1,5 @@ extends Button -@onready var response_label: Label = $"/root/Playground/UI/MarginContainer/ResponseLabel" - func _ready() -> void: _set_text(_get_value()) @@ -20,4 +18,4 @@ func _on_pressed() -> void: not enabled ) _set_text(not enabled) - response_label.text = "Continuity is now " + ("enabled" if not enabled else "disabled") + %ResponseLabel.text = "Continuity is now " + ("enabled" if not enabled else "disabled") diff --git a/addons/talo/samples/playground/scripts/toggle_network_button.gd b/addons/talo/samples/playground/scripts/toggle_network_button.gd index b93f230..aba60d9 100644 --- a/addons/talo/samples/playground/scripts/toggle_network_button.gd +++ b/addons/talo/samples/playground/scripts/toggle_network_button.gd @@ -1,7 +1,5 @@ extends Button -@onready var response_label: Label = $"/root/Playground/UI/MarginContainer/ResponseLabel" - func _ready() -> void: _set_text(Talo.offline_mode_enabled()) @@ -17,4 +15,4 @@ func _on_pressed() -> void: not offline ) _set_text(not offline) - response_label.text = "You are now " + ("offline" if not offline else "online") + %ResponseLabel.text = "You are now " + ("offline" if not offline else "online") diff --git a/addons/talo/samples/playground/scripts/track_event_button.gd b/addons/talo/samples/playground/scripts/track_event_button.gd new file mode 100644 index 0000000..f6b32fa --- /dev/null +++ b/addons/talo/samples/playground/scripts/track_event_button.gd @@ -0,0 +1,23 @@ +extends Button + +@export var event_name: String +@export var event_props: Dictionary = { + "prop1": "value1" +} +@export var flush_immediately: bool + +func _on_pressed() -> void: + if Talo.identity_check() != OK: + %ResponseLabel.text = "You need to identify a player first!" + return + + if event_name.is_empty(): + %ResponseLabel.text = "event_name not set on TrackEventButton" + return + + Talo.events.track(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] diff --git a/addons/talo/samples/playground/scripts/track_stat_button.gd b/addons/talo/samples/playground/scripts/track_stat_button.gd new file mode 100644 index 0000000..085c1d4 --- /dev/null +++ b/addons/talo/samples/playground/scripts/track_stat_button.gd @@ -0,0 +1,15 @@ +extends Button + +@export var stat_name: String + +func _on_pressed() -> void: + if Talo.identity_check() != OK: + %ResponseLabel.text = "You need to identify a player first!" + return + + if stat_name.is_empty(): + %ResponseLabel.text = "stat_name not set on TrackStatButton" + return + + Talo.stats.track(stat_name) + %ResponseLabel.text = "Stat incremented: %s" % stat_name diff --git a/addons/talo/samples/playground/scripts/update_save_button.gd b/addons/talo/samples/playground/scripts/update_save_button.gd index 238e7f5..87c65e1 100644 --- a/addons/talo/samples/playground/scripts/update_save_button.gd +++ b/addons/talo/samples/playground/scripts/update_save_button.gd @@ -14,6 +14,6 @@ func _on_pressed() -> void: if result: version = int(result.get_string(1)) - var new_name = Talo.saves.current.display_name.replace("version %s" % [version], "version %s" % [version + 1]) + var new_name = Talo.saves.current.display_name.replace("version %s" % version, "version %s" % (version + 1)) Talo.saves.update_current_save(new_name) diff --git a/addons/talo/samples/saves/loadable_button.gd b/addons/talo/samples/saves/loadable_button.gd index 3c89a73..5e7d515 100644 --- a/addons/talo/samples/saves/loadable_button.gd +++ b/addons/talo/samples/saves/loadable_button.gd @@ -11,7 +11,7 @@ func register_fields() -> void: register_field("clicks", clicks) func _set_button_text() -> void: - button.text = "%s clicks" % [clicks] + button.text = "%s clicks" % clicks func on_loaded(data: Dictionary) -> void: clicks = data["clicks"] diff --git a/addons/talo/utils/continuity_manager.gd b/addons/talo/utils/continuity_manager.gd index 0989fa7..2d5e031 100644 --- a/addons/talo/utils/continuity_manager.gd +++ b/addons/talo/utils/continuity_manager.gd @@ -46,7 +46,7 @@ func _read_requests() -> Array: var content = FileAccess.open_encrypted_with_pass(_continuity_path, FileAccess.READ, Talo.crypto_manager.get_key()) if content == null: - DirAccess.remove_absolute(_continuity_path) + TaloCryptoManager.handle_undecryptable_file(_continuity_path, "continuity file") return [] var json = JSON.new() diff --git a/addons/talo/utils/crypto_manager.gd b/addons/talo/utils/crypto_manager.gd index cb44ab9..bfae061 100644 --- a/addons/talo/utils/crypto_manager.gd +++ b/addons/talo/utils/crypto_manager.gd @@ -2,6 +2,12 @@ class_name TaloCryptoManager extends Node var _key_file_path = "user://ti.bin" +static func handle_undecryptable_file(path: String, what: String) -> void: + push_error("Failed to decrypt %s" % what) + var split_path = path.split(".") + var timestamp = TimeUtils.get_timestamp_msec() + DirAccess.rename_absolute(path, "%s-invalid-%s.%s" % [split_path[0], timestamp, split_path[1]]) + func _get_pass() -> String: if OS.has_feature("web"): return Talo.settings.get_value("", "access_key") @@ -14,19 +20,22 @@ func _init() -> void: push_error("Unable to create key file: cannot generate a suitable password") return - var crypto = Crypto.new() - var key = crypto.generate_random_bytes(32).hex_encode() + var crypto = Crypto.new() + var key = crypto.generate_random_bytes(32).hex_encode() - var file = FileAccess.open_encrypted_with_pass(_key_file_path, FileAccess.WRITE, _get_pass()) - file.store_line(key) - file.close() + var file = FileAccess.open_encrypted_with_pass(_key_file_path, FileAccess.WRITE, _get_pass()) + file.store_line(key) + file.close() func get_key() -> String: if not FileAccess.file_exists(_key_file_path): - push_error("Talo key file has not been created") - return "" + _init() var file = FileAccess.open_encrypted_with_pass(_key_file_path, FileAccess.READ, _get_pass()) + if file == null: + handle_undecryptable_file(_key_file_path, "crypto init file") + return "" + var key = file.get_as_text() file.close() return key diff --git a/addons/talo/utils/saves_manager.gd b/addons/talo/utils/saves_manager.gd index 74daa4c..10a461e 100644 --- a/addons/talo/utils/saves_manager.gd +++ b/addons/talo/utils/saves_manager.gd @@ -13,6 +13,10 @@ func read_offline_saves() -> Array[TaloGameSave]: return [] var content = FileAccess.open_encrypted_with_pass(_offline_saves_path, FileAccess.READ, Talo.crypto_manager.get_key()) + if content == null: + TaloCryptoManager.handle_undecryptable_file(_offline_saves_path, "offline saves file") + return [] + var json = JSON.new() json.parse(content.get_as_text()) @@ -97,7 +101,7 @@ func get_save_content() -> Dictionary: func replace_save(new_save: TaloGameSave) -> void: var existing_saves = all_saves.filter(func (save): return save.id == new_save.id) if existing_saves.is_empty(): - push_error("Save %s cannot be replaced as it does not exist" % [new_save.id]) + push_error("Save %s cannot be replaced as it does not exist" % new_save.id) all_saves.push_back(new_save) else: all_saves[all_saves.find(existing_saves.front())] = new_save