Fixed add player process where name can be set. Added signals for points. Added settings file. Changed some shortcuts.
This commit is contained in:
@@ -4,13 +4,11 @@ extends Control
|
||||
# 2. Fix reset buttons
|
||||
# 3. Fix settings
|
||||
# 4. Fix top buttons
|
||||
# 5. Fix player name
|
||||
# 7. Fix welcome into the game
|
||||
# 8. Fix match ball sound
|
||||
# 9. Fix winner
|
||||
# 10. Fix jump between songs
|
||||
# 11. Refactor components
|
||||
# 12. Change add player
|
||||
# 13. Fix graphics in lists
|
||||
# 14. Fix layout
|
||||
# 15. Fix for local play
|
||||
@@ -51,7 +49,16 @@ var progress := $PanelContainer/HBoxContainer/HSlider
|
||||
var label := $PanelContainer/HBoxContainer/Label
|
||||
|
||||
@onready
|
||||
var add_player := $Players/VBoxContainer/HBoxContainer/AddPlayer
|
||||
var add_player_container := $Players/VBoxContainer/AddPlayerContainer
|
||||
|
||||
@onready
|
||||
var add_players_button := $Players/VBoxContainer/HBoxContainer/AddPlayersButton
|
||||
|
||||
@onready
|
||||
var add_player_button := $Players/VBoxContainer/AddPlayerContainer/AddPlayerButton
|
||||
|
||||
@onready
|
||||
var new_player_name_field := $Players/VBoxContainer/AddPlayerContainer/PlayerNameField
|
||||
|
||||
@onready
|
||||
var sound_test_button := $SoundTestButton
|
||||
@@ -104,8 +111,9 @@ func _ready():
|
||||
progress.drag_started.connect(_on_drag_started)
|
||||
progress.drag_ended.connect(_on_drag_ended)
|
||||
character_select.connect("character_selected", _on_character_selected)
|
||||
|
||||
add_player.pressed.connect(add_players)
|
||||
new_player_name_field.connect("enter_key_pressed", add_player)
|
||||
add_players_button.pressed.connect(add_players)
|
||||
add_player_button.pressed.connect(add_player)
|
||||
|
||||
open_button.pressed.connect(open)
|
||||
get_suggestion_list()
|
||||
@@ -122,7 +130,7 @@ func get_sound_test_song():
|
||||
progress.max_value = round(stream.get_length())
|
||||
progress.tick_count = round(stream.get_length() / 60)
|
||||
|
||||
make_request("https://music.sanplex.tech/music/first", play_sound_test_song)
|
||||
make_request(Settings.default_path + "/music/first", play_sound_test_song)
|
||||
|
||||
func sound_test_local():
|
||||
path = "res://01. Opening.mp3"
|
||||
@@ -138,7 +146,7 @@ func sync_games():
|
||||
http_request.request_completed.connect(games_synced)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var error = http_request.request("https://music.sanplex.tech/sync")
|
||||
var error = http_request.request(Settings.default_path + "/sync")
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
@@ -152,12 +160,18 @@ func get_suggestion_list() -> void:
|
||||
http_request.request_completed.connect(_http_request_completed)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var error = http_request.request("https://music.sanplex.tech/music/all")
|
||||
var error = http_request.request(Settings.default_path + "/music/all")
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
func add_players():
|
||||
add_player_container.visible = !add_player_container.visible
|
||||
new_player_name_field.grab_focus()
|
||||
|
||||
func add_player():
|
||||
var new_player := Player.instantiate()
|
||||
new_player.new_name(new_player_name_field.text)
|
||||
new_player_name_field.text = ""
|
||||
players.add_child(new_player)
|
||||
new_player.connect("change_character_clicked", _on_player_change_character_clicked.bind(new_player))
|
||||
|
||||
@@ -173,7 +187,7 @@ func show_answer():
|
||||
http_request.request_completed.connect(show_fetched)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var error = http_request.request("https://music.sanplex.tech/music/info")
|
||||
var error = http_request.request(Settings.default_path + "/music/info")
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
@@ -183,7 +197,7 @@ func fetched():
|
||||
http_request2.request_completed.connect(show_fetched_list)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var error2 = http_request2.request("https://music.sanplex.tech/music/list")
|
||||
var error2 = http_request2.request(Settings.default_path + "/music/list")
|
||||
if error2 != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
@@ -335,11 +349,10 @@ func format_text(part: float, total: float) -> String:
|
||||
func fetch_next_song() -> void:
|
||||
var http_request = HTTPRequest.new()
|
||||
add_child(http_request)
|
||||
#http.set_download_file("https://music.sanplex.tech/music/first")
|
||||
http_request.request_completed.connect(first_song_fetched)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var error = http_request.request("https://music.sanplex.tech/music/rand")
|
||||
var error = http_request.request(Settings.default_path + "/music/rand")
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
@@ -351,7 +364,7 @@ func first_song_fetched(result, response_code, headers, body) -> void:
|
||||
push_error("Song couldn't be downloaded. Try a different song.")
|
||||
var sound = AudioStreamMP3.new()
|
||||
sound.data = body
|
||||
make_request("https://music.sanplex.tech/music/addQue", add_que)
|
||||
make_request(Settings.default_path + "/music/addQue", add_que)
|
||||
print("play given song")
|
||||
audio.stream = sound
|
||||
audio.play()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=15 format=3 uid="uid://xwq863o6uvsu"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://xwq863o6uvsu"]
|
||||
|
||||
[ext_resource type="Script" path="res://MainWindow.gd" id="1_eu0t5"]
|
||||
[ext_resource type="PackedScene" uid="uid://b16on0oscg1bv" path="res://CharacterSelect.tscn" id="2_76kf4"]
|
||||
@@ -7,6 +7,7 @@
|
||||
[ext_resource type="AudioStream" uid="uid://n2g8jddr85h2" path="res://01. Opening.mp3" id="4_5kvsq"]
|
||||
[ext_resource type="Texture2D" uid="uid://o5go6smk7hm1" path="res://person_add_alt_1-black-36dp.svg" id="4_op458"]
|
||||
[ext_resource type="Script" path="res://MusicListScrollContainer.gd" id="7_dj026"]
|
||||
[ext_resource type="Script" path="res://PlayerNameField.gd" id="7_qsdfy"]
|
||||
[ext_resource type="Theme" uid="uid://rxexo3ur85as" path="res://LightGrayTheme.tres" id="7_wxbv6"]
|
||||
[ext_resource type="PackedScene" uid="uid://bxydgil1yifps" path="res://SearchWindow.tscn" id="9_5ijvr"]
|
||||
|
||||
@@ -19,9 +20,18 @@ font_size = 50
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_3m52w"]
|
||||
font_size = 35
|
||||
|
||||
[sub_resource type="InputEventKey" id="InputEventKey_03bm3"]
|
||||
device = -1
|
||||
alt_pressed = true
|
||||
keycode = 65
|
||||
unicode = 63743
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_jafqj"]
|
||||
events = [SubResource("InputEventKey_03bm3")]
|
||||
|
||||
[sub_resource type="InputEventKey" id="InputEventKey_ujjlu"]
|
||||
device = -1
|
||||
command_or_control_autoremap = true
|
||||
alt_pressed = true
|
||||
keycode = 83
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_fbju4"]
|
||||
@@ -168,11 +178,36 @@ size_flags_horizontal = 3
|
||||
text = "Players"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="AddPlayer" type="TextureButton" parent="Players/VBoxContainer/HBoxContainer"]
|
||||
[node name="AddPlayersButton" type="TextureButton" parent="Players/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
shortcut = SubResource("Shortcut_jafqj")
|
||||
texture_normal = ExtResource("4_op458")
|
||||
|
||||
[node name="AddPlayerContainer" type="HBoxContainer" parent="Players/VBoxContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Panel" type="Panel" parent="Players/VBoxContainer/AddPlayerContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="PlayerNameField" type="TextEdit" parent="Players/VBoxContainer/AddPlayerContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Player name"
|
||||
script = ExtResource("7_qsdfy")
|
||||
|
||||
[node name="AddPlayerButton" type="Button" parent="Players/VBoxContainer/AddPlayerContainer"]
|
||||
layout_mode = 2
|
||||
text = "Add"
|
||||
|
||||
[node name="Panel2" type="Panel" parent="Players/VBoxContainer/AddPlayerContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="ResetPlaylistButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 125.0
|
||||
|
||||
40
Player.gd
40
Player.gd
@@ -1,7 +1,7 @@
|
||||
extends Control
|
||||
|
||||
@onready
|
||||
var player_name := $HBoxContainer/Name
|
||||
var player_name_field := $HBoxContainer/Name
|
||||
|
||||
@onready
|
||||
var points := $HBoxContainer/Points
|
||||
@@ -16,29 +16,47 @@ var minus := $HBoxContainer/RemovePoint
|
||||
var character := $HBoxContainer/Character
|
||||
|
||||
signal change_character_clicked
|
||||
signal first_point_triggerd
|
||||
signal match_point_triggerd
|
||||
signal winner_triggerd
|
||||
|
||||
var player_name: String
|
||||
|
||||
var is_first_point: bool = true
|
||||
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
print("_ready")
|
||||
add.pressed.connect(add_point)
|
||||
minus.pressed.connect(minus_point)
|
||||
character.pressed.connect(change_character)
|
||||
player_name.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
player_name.gui_input.connect(name_clicked)
|
||||
player_name_field.text = player_name
|
||||
|
||||
func name_clicked(event):
|
||||
if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT):
|
||||
print("Clicked: " + player_name.text)
|
||||
func new_name(new_name: String):
|
||||
player_name = new_name
|
||||
|
||||
func add_point():
|
||||
var value := int(points.text)
|
||||
points.text = str(value + 1)
|
||||
if is_first_point:
|
||||
is_first_point = false
|
||||
first_point_triggerd.emit()
|
||||
|
||||
var new_value := int(points.text) + 1
|
||||
points.text = str(new_value)
|
||||
|
||||
if new_value == Settings.winning_score - 1:
|
||||
match_point_triggerd.emit()
|
||||
|
||||
if new_value == Settings.winning_score:
|
||||
winner_triggerd.emit()
|
||||
|
||||
func minus_point():
|
||||
var value := int(points.text)
|
||||
points.text = str(value - 1)
|
||||
var new_value := int(points.text) - 1
|
||||
points.text = str(new_value)
|
||||
|
||||
if new_value == 0:
|
||||
is_first_point = true
|
||||
|
||||
func change_character():
|
||||
print("change_character")
|
||||
change_character_clicked.emit()
|
||||
|
||||
12
PlayerNameField.gd
Normal file
12
PlayerNameField.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends TextEdit
|
||||
|
||||
signal enter_key_pressed
|
||||
signal close_pressed
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.alt_pressed && event.keycode == KEY_A:
|
||||
close_pressed.emit()
|
||||
|
||||
if event.keycode == KEY_ENTER:
|
||||
enter_key_pressed.emit()
|
||||
@@ -21,6 +21,7 @@ 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())
|
||||
|
||||
func close():
|
||||
clear()
|
||||
@@ -47,7 +48,7 @@ func get_list_of_games() -> void:
|
||||
http_request.request_completed.connect(self._http_request_completed)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var error = http_request.request("https://music.sanplex.tech/music/all/order")
|
||||
var error = http_request.request(Settings.default_path + "/music/all/order")
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
|
||||
23
Settings.gd
Normal file
23
Settings.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
extends Node
|
||||
|
||||
var default_path: String = "http://192.168.86.100:8085"
|
||||
#var default_path: String = "https://music.sanplex.tech"
|
||||
|
||||
var is_local: bool = false
|
||||
|
||||
var stop_after_current: bool = false
|
||||
var hide_next_track: bool = false
|
||||
var add_to_stats: bool = false
|
||||
var use_low_played_mode: bool = false
|
||||
var winning_score: int = 20
|
||||
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
@@ -16,6 +16,10 @@ config/features=PackedStringArray("4.1", "Forward Plus")
|
||||
run/low_processor_mode=true
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
||||
Settings="*res://Settings.gd"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1920
|
||||
|
||||
Reference in New Issue
Block a user