Fixed sounds effects with points. Fixed buttons statistics and about

This commit is contained in:
2023-09-08 22:14:54 +02:00
parent 050d19039c
commit c9ea40215d
4 changed files with 103 additions and 6 deletions

View File

@@ -3,9 +3,6 @@ extends Control
##TODO
# 2. Fix reset buttons
# 3. Fix settings
# 4. Fix top buttons
# 7. Fix welcome into the game
# 8. Fix match ball sound
# 9. Fix winner
# 10. Fix jump between songs
# 11. Refactor components
@@ -69,6 +66,21 @@ var sync_button := $SyncButton
@onready
var sync_popup := $PopupPanel
@onready
var statistics_button := $StatisticsButton
@onready
var statistic_popup := $StatisticsPopupPanel
@onready
var statistic_label := $StatisticsPopupPanel/StatisticsLabel
@onready
var about_button := $AboutButton
@onready
var about_popup := $AboutPopupPanel
@onready
var show_answer_button := $ShowAnswerButton
@@ -107,6 +119,8 @@ func _ready():
search_button.pressed.connect(show_search)
sync_button.pressed.connect(sync_games)
sound_test_button.pressed.connect(get_sound_test_song)
statistics_button.pressed.connect(get_statistics)
about_button.pressed.connect(show_about)
progress.drag_started.connect(_on_drag_started)
progress.drag_ended.connect(_on_drag_ended)
@@ -118,6 +132,13 @@ func _ready():
open_button.pressed.connect(open)
get_suggestion_list()
func show_about():
about_popup.visible = true
func get_statistics():
statistic_popup.visible = true
statistic_label.text = "Total amount of games in the playlist: " + str(games.size())
func get_sound_test_song():
var play_sound_test_song = func(result, response_code, headers, body):
if result != HTTPRequest.RESULT_SUCCESS:
@@ -174,6 +195,30 @@ func add_player():
new_player_name_field.text = ""
players.add_child(new_player)
new_player.connect("change_character_clicked", _on_player_change_character_clicked.bind(new_player))
new_player.connect("first_point_triggerd", _on_point_triggerd.bind("first"))
new_player.connect("match_point_triggerd", _on_point_triggerd.bind("match"))
new_player.connect("winner_triggerd", _on_point_triggerd.bind("winner"))
func _on_point_triggerd(point: String):
var song_path: String
if point == "first":
var value = randi_range(0, 10)
if value == 0:
song_path = "res://sounds/sound1.mp3"
elif value < 5:
song_path = "res://sounds/intro_long.mp3"
else:
song_path = "res://sounds/intro_short.mp3"
elif point == "match":
song_path = "res://sounds/sound0.mp3"
elif point == "winner":
song_path = "res://sounds/winning.mp3"
audio.stream = load_mp3(song_path)
audio.play()
stream = audio.stream
progress.max_value = round(stream.get_length())
progress.tick_count = round(stream.get_length() / 60)
func show_search():
if search_view.visible == false:

View File

@@ -326,4 +326,47 @@ text = "Games synced!"
horizontal_alignment = 1
vertical_alignment = 1
[node name="StatisticsPopupPanel" type="PopupPanel" parent="."]
initial_position = 2
size = Vector2i(450, 100)
[node name="Label" type="Label" parent="StatisticsPopupPanel"]
offset_left = 4.0
offset_top = 4.0
offset_right = 446.0
offset_bottom = 96.0
text = "Statistics"
horizontal_alignment = 1
[node name="StatisticsLabel" type="Label" parent="StatisticsPopupPanel"]
offset_left = 4.0
offset_top = 4.0
offset_right = 446.0
offset_bottom = 96.0
text = "Total amount of games in the playlist: 9000"
horizontal_alignment = 1
vertical_alignment = 1
[node name="AboutPopupPanel" type="PopupPanel" parent="."]
initial_position = 2
size = Vector2i(450, 100)
[node name="Label" type="Label" parent="AboutPopupPanel"]
offset_left = 4.0
offset_top = 4.0
offset_right = 446.0
offset_bottom = 96.0
text = "Music Player Randomizer v0.6"
horizontal_alignment = 1
[node name="AboutLabel" type="Label" parent="AboutPopupPanel"]
offset_left = 4.0
offset_top = 4.0
offset_right = 446.0
offset_bottom = 96.0
text = "Try your video game music knowledge with this VGM randomizer, invite your friends and see who is the best."
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2
[connection signal="dir_selected" from="FileDialog" to="." method="_on_file_dialog_dir_selected"]

View File

@@ -21,7 +21,11 @@ func _ready():
close_button.pressed.connect(close)
search_bar.grab_focus()
search_bar.text_changed.connect(search)
visibility_changed.connect(func(): search_bar.grab_focus())
visibility_changed.connect(focus)
func focus():
if self.visible == true:
search_bar.grab_focus()
func close():
clear()

View File

@@ -1,7 +1,7 @@
extends Node
var default_path: String = "http://192.168.86.100:8085"
#var default_path: String = "https://music.sanplex.tech"
#var default_path: String = "http://192.168.86.100:8085"
var default_path: String = "https://music.sanplex.tech"
var is_local: bool = false
@@ -12,6 +12,11 @@ var use_low_played_mode: bool = false
var winning_score: int = 20
#play = X
#nästa = c
#visa svar = v
#lägga till poäng? 1, 2, 3, 4, 5, 6
# Called when the node enters the scene tree for the first time.
func _ready():