From d76552b094d1d16d896af158488797adecf0a6a1 Mon Sep 17 00:00:00 2001 From: Niraculix <75939533+Niraculix@users.noreply.github.com> Date: Thu, 9 May 2024 21:37:11 +0200 Subject: [PATCH 1/2] Added Round Duration --- scenes/menu.tscn | 16 +++++++++++++++- scripts/menu.gd | 6 +++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/scenes/menu.tscn b/scenes/menu.tscn index 08c7b7a..b6b92fc 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -1,7 +1,10 @@ -[gd_scene load_steps=2 format=3 uid="uid://yyc1l3e78qgl"] +[gd_scene load_steps=3 format=3 uid="uid://yyc1l3e78qgl"] [ext_resource type="Script" path="res://scripts/menu.gd" id="1_f4qtc"] +[sub_resource type="Theme" id="Theme_31w7n"] +default_font_size = 70 + [node name="Menu" type="CanvasLayer"] script = ExtResource("1_f4qtc") @@ -59,4 +62,15 @@ layout_direction = 3 layout_mode = 2 alignment = 2 +[node name="RoundDuration" type="SpinBox" parent="."] +offset_left = 54.0 +offset_top = 190.0 +offset_right = 326.225 +offset_bottom = 278.0 +theme = SubResource("Theme_31w7n") +min_value = 5.0 +max_value = 90.0 +value = 30.0 +suffix = "s" + [connection signal="pressed" from="Start" to="." method="on_btn_start_pressed"] diff --git a/scripts/menu.gd b/scripts/menu.gd index ca90249..4edbadc 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -1,11 +1,14 @@ class_name Menu extends CanvasLayer ## Time for each round in seconds -var round_duration: int = 30 +var round_duration: int ## ready is called when the node enters the scene tree for the first time. func _ready(): $ModeSelect.add_item("Streamer VS Chat", 0) + if(scene_manager.round_duration > 0): + round_duration = scene_manager.round_duration + $RoundDuration.value = round_duration api.category(on_category_response) ## on_category_response is called as when the categories api call completed. @@ -27,6 +30,7 @@ func update_category_list(categories: Dictionary): ## on_btn_start_pressed is called when pressed the start game button. ## It collects all the selected categories and creates a new game on the server. func on_btn_start_pressed(): + round_duration = $RoundDuration.value var categories: Dictionary = {} for category: HBoxContainer in $CategoryBox/Categories.get_children(): var amount: int = category.get_child(0).value From b6e5f55a52dfdd932dcdf0d418639f5869553410 Mon Sep 17 00:00:00 2001 From: Niraculix <75939533+Niraculix@users.noreply.github.com> Date: Thu, 9 May 2024 21:37:49 +0200 Subject: [PATCH 2/2] Bug fixes - fixed style issue "@" - Crash at end of round --- scripts/game_end.gd | 5 ++++- scripts/question_end.gd | 5 ++++- scripts/scene_manager.gd | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/game_end.gd b/scripts/game_end.gd index 559b485..6a7438b 100644 --- a/scripts/game_end.gd +++ b/scripts/game_end.gd @@ -25,7 +25,10 @@ func show_round_data(data: Dictionary): answer.color = Color.hex(0x004200ff) $StreamerAnswer.color = Color.hex(0x004200ff) if data.streamer_vote == data.correct else Color.hex(0x780000ff) - $StreamerAnswer/Label.text = "You voted %s" % [String.chr(65 + data.streamer_vote - 1)] + if data.streamer_vote == 0: + $StreamerAnswer/Label.text = "You voted nothing" + else: + $StreamerAnswer/Label.text = "You voted %s" % [String.chr(64 + data.streamer_vote)] var total_votes: int = data.chat_vote_count[0] + data.chat_vote_count[1] + data.chat_vote_count[2] + data.chat_vote_count[3] diff --git a/scripts/question_end.gd b/scripts/question_end.gd index 3007db5..6359738 100644 --- a/scripts/question_end.gd +++ b/scripts/question_end.gd @@ -25,7 +25,10 @@ func show_round_data(data: Dictionary): answer.color = Color.hex(0x004200ff) $StreamerAnswer.color = Color.hex(0x004200ff) if data.streamer_vote == data.correct else Color.hex(0x780000ff) - $StreamerAnswer/Label.text = "You voted %s" % [String.chr(65 + data.streamer_vote - 1)] + if data.streamer_vote == 0: + $StreamerAnswer/Label.text = "You voted nothing" + else: + $StreamerAnswer/Label.text = "You voted %s" % [String.chr(64 + data.streamer_vote)] var total_votes: int = data.chat_vote_count[0] + data.chat_vote_count[1] + data.chat_vote_count[2] + data.chat_vote_count[3] diff --git a/scripts/scene_manager.gd b/scripts/scene_manager.gd index d6542d6..d961563 100644 --- a/scripts/scene_manager.gd +++ b/scripts/scene_manager.gd @@ -13,3 +13,4 @@ func change_scene(from: Node, to_scene_name: String): var scene_path = scene_path_format % [to_scene_name] from.get_tree().call_deferred("change_scene_to_file", scene_path) + api.got_ws_message = Callable()