#4 #5 Added a new character select window that now fetches images from the server
All checks were successful
Build / build (push) Successful in 1m31s
Publish / build (push) Successful in 2m39s

This commit is contained in:
2025-11-07 20:46:45 +01:00
parent 734a463db9
commit 166705f2ab
15 changed files with 327 additions and 61 deletions

View File

@@ -94,6 +94,9 @@ var player_container: VBoxContainer = $Players/VBoxContainer
@onready
var character_select: Control = $CharacterSelect
@onready
var new_character_select: Control = %NewCharacterSelect
@onready
var search_button: Button = $SearchButton
@@ -116,10 +119,10 @@ var coming_label: Label = $AboutPopupPanel/VBoxContainer/HBoxContainer/CommingLa
var winner_popup: PopupPanel = $WinnerPopupPanel
@onready
var winner_label: Label = $WinnerPopupPanel/WinnerLabel
var winner_label: Label = %WinnerLabel
@onready
var winner_picture: TextureRect = $WinnerPopupPanel/WinnerPicture
var winner_picture: TextureRect = %WinnerPicture
@onready
var auto_repeat_song_button: CheckButton = $RepeatSongCheckButton
@@ -162,6 +165,7 @@ func _ready() -> void:
reset_points_button.pressed.connect(reset_points)
character_select.connect("character_selected", _on_character_selected)
new_character_select.connect("new_new_character_selected", _on_new_character_selected)
new_player_name_field.connect("enter_key_pressed", add_player)
music_player_container.connect("play_next_song", play_next_song)
music_player_container.connect("update_song_list", update_song_list)
@@ -178,6 +182,8 @@ func _ready() -> void:
get_suggestion_list()
fetch_song_list_at_start()
fetch_song()
search_view.get_list_of_games()
new_character_select.load_characters()
func _input(event: InputEvent) -> void:
if event is InputEventKey and event.pressed:
@@ -214,6 +220,7 @@ func update_from_server() -> void:
search_view.get_list_of_games()
get_suggestion_list()
reset_playlist()
new_character_select.load_characters()
func repeat_song() -> void:
Settings.auto_repeat_song = !Settings.auto_repeat_song
@@ -314,17 +321,18 @@ func update_song_list() -> void:
func song_object_clicked(event: InputEvent, song_no: int) -> void:
if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT):
print("Clicked Song Object: ", Playlist.song_object_array[song_no].to_string())
if Playlist.get_song(song_no) == null:
print("has no song, need to download")
var song_downloaded: Callable = func song_downloaded(body: PackedByteArray) -> void:
var sound: AudioStream = AudioStreamMP3.new()
sound.data = body
Playlist.add_song_to_song_object(song_no, sound)
if Settings.character_select_open == false:
if Playlist.get_song(song_no) == null:
print("has no song, need to download")
var song_downloaded: Callable = func song_downloaded(body: PackedByteArray) -> void:
var sound: AudioStream = AudioStreamMP3.new()
sound.data = body
Playlist.add_song_to_song_object(song_no, sound)
music_player_container.play_song_object(song_no)
Settings.make_request2("/music?song=" + str(song_no), song_downloaded, true)
else:
print("song already downloaded")
music_player_container.play_song_object(song_no)
Settings.make_request2("/music?song=" + str(song_no), song_downloaded, true)
else:
print("song already downloaded")
music_player_container.play_song_object(song_no)
func reset_playlist() -> void:
print("reset_playlist")
@@ -451,9 +459,9 @@ func _on_player_won(winning_player_id: int) -> void:
print("_on_player_won")
winner_popup.visible = true
winner_label.text = Settings.player_array[winning_player_id].player_name + " won!!"
winner_picture.custom_minimum_size = Vector2(80, 40)
winner_picture.ignore_texture_size = true
winner_picture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT
winner_picture.custom_minimum_size = Vector2(692, 300)
winner_picture.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL
winner_picture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
winner_picture.texture = Settings.player_array[winning_player_id].character
music_player_container.play_sound(preload("res://sounds/winning.mp3"))
@@ -467,12 +475,16 @@ func _on_player_removed(player_to_remove: int) -> void:
func _on_player_change_character_clicked(new_player: Node) -> void:
print("_on_player_change_character_clicked")
current_player = new_player
character_select.visible = true
new_character_select.show_grid()
func _on_character_selected(file_name: String) -> void:
print("_on_character_selected")
character_select.visible = false
current_player._on_control_character_selected_clicked(file_name)
current_player.character_selected(file_name)
func _on_new_character_selected(character_texture: ImageTexture) -> void:
print("_on_new_character_selected")
current_player.new_character_selected(character_texture)
func show_search() -> void:
print("show_search")

View File

@@ -1,10 +1,11 @@
[gd_scene load_steps=27 format=3 uid="uid://xwq863o6uvsu"]
[gd_scene load_steps=28 format=3 uid="uid://xwq863o6uvsu"]
[ext_resource type="Script" uid="uid://b8f4g15cas2j2" path="res://MainWindow.gd" id="1_eu0t5"]
[ext_resource type="PackedScene" uid="uid://b16on0oscg1bv" path="res://CharacterSelect.tscn" id="2_76kf4"]
[ext_resource type="Script" uid="uid://elgn7gkxgagq" path="res://InsperationScrollContainer.gd" id="2_gxtxm"]
[ext_resource type="Texture2D" uid="uid://bcfmpd7h512ef" path="res://icons/person_add_light.svg" id="5_31tjv"]
[ext_resource type="PackedScene" uid="uid://ds15cgsf8vpvc" path="res://MusicPlayer.tscn" id="5_emn36"]
[ext_resource type="PackedScene" uid="uid://cdy4kvemwaiom" path="res://new_character_select.tscn" id="6_dhrvg"]
[ext_resource type="Script" uid="uid://gf1bk6xbe3j" path="res://MusicListScrollContainer.gd" id="7_dj026"]
[ext_resource type="Script" uid="uid://cgakje8gb37tf" path="res://PlayerNameField.gd" id="7_qsdfy"]
[ext_resource type="Theme" uid="uid://rxexo3ur85as" path="res://LightGrayTheme.tres" id="7_wxbv6"]
@@ -390,6 +391,15 @@ offset_top = 153.0
offset_right = 720.0
offset_bottom = 153.0
[node name="NewCharacterSelect" parent="." instance=ExtResource("6_dhrvg")]
unique_name_in_owner = true
visible = false
layout_mode = 1
offset_left = 420.0
offset_top = 165.0
offset_right = 1572.0
offset_bottom = 805.0
[node name="StatisticsPopupPanel" type="PopupPanel" parent="."]
oversampling_override = 1.0
initial_position = 2
@@ -477,24 +487,39 @@ Add shortcuts"
autowrap_mode = 2
[node name="WinnerPopupPanel" type="PopupPanel" parent="."]
oversampling_override = 1.0
initial_position = 2
size = Vector2i(600, 350)
size = Vector2i(700, 350)
[node name="WinnerPicture" type="TextureRect" parent="WinnerPopupPanel"]
[node name="Panel" type="Panel" parent="WinnerPopupPanel"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 4.0
offset_top = 4.0
offset_right = 596.0
offset_bottom = 346.0
offset_right = -4.0
offset_bottom = -4.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="WinnerPopupPanel/Panel"]
layout_mode = 0
offset_right = 692.0
offset_bottom = 342.0
alignment = 1
[node name="WinnerPicture" type="TextureRect" parent="WinnerPopupPanel/Panel/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(692, 300)
layout_mode = 2
texture = ExtResource("11_1qef0")
expand_mode = 2
stretch_mode = 4
expand_mode = 3
stretch_mode = 5
[node name="WinnerLabel" type="Label" parent="WinnerPopupPanel"]
[node name="WinnerLabel" type="Label" parent="WinnerPopupPanel/Panel/VBoxContainer"]
unique_name_in_owner = true
texture_filter = 1
offset_left = 4.0
offset_top = 4.0
offset_right = 596.0
offset_bottom = 346.0
layout_mode = 2
text = "Sansan won!!"
label_settings = SubResource("LabelSettings_hr75l")
horizontal_alignment = 1

View File

@@ -56,15 +56,20 @@ func minus_point() -> void:
func change_character() -> void:
change_character_clicked.emit()
func _on_control_character_selected_clicked(file_name: String) -> void:
func character_selected(file_name: String) -> void:
print("Back in player list with: " + file_name)
Settings.player_array[id].character = load("res://characters/" + file_name)
set_player_character()
func new_character_selected(character_texture: ImageTexture) -> void:
print("Back in player list with new")
Settings.player_array[id].character = character_texture
set_player_character()
func set_player_character() -> void:
character.custom_minimum_size = Vector2(80, 40)
character.ignore_texture_size = true
character.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT
character.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT_CENTERED
character.texture_normal = Settings.player_array[id].character
func update_score() -> void:

View File

@@ -1,22 +1,24 @@
extends Control
@onready
var search_list := $ScrollContainer/VBoxContainer
var search_list: VBoxContainer = $ScrollContainer/VBoxContainer
@onready
var clear_button := $ClearButton
var search_panel: Panel = %SearchPanel
@onready
var close_button := $CloseButton
var clear_button: Button = $ClearButton
@onready
var search_bar := $Searchbar
var close_button: Button = $CloseButton
var games := []
@onready
var search_bar: TextEdit = $Searchbar
var games: Array = []
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
get_list_of_games()
clear_button.pressed.connect(clear)
close_button.pressed.connect(close)
search_bar.grab_focus()
@@ -100,7 +102,7 @@ func compile_regex(search_term: String) -> RegEx:
func get_list_of_games() -> void:
print("get_list_of_games")
var handle_games = func handle_games(array):
var handle_games: Callable = func handle_games(array) -> void:
if typeof(array) == TYPE_ARRAY:
games = []
Settings.delete_children(search_list)
@@ -114,6 +116,13 @@ func get_list_of_games() -> void:
print("Unexpected data")
Settings.make_request2("/music/all/order", handle_games, true)
func _input(event: InputEvent) -> void:
if self.visible == true:
if event is InputEventMouseButton && event.is_pressed():
var evLocal: InputEvent = make_input_local(event)
if !Rect2(Vector2(0, 0), search_panel.size).has_point(evLocal.position):
self.visible = false
func clear() -> void:
search_bar.text = ""
search()

View File

@@ -11,7 +11,8 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_m7bij")
[node name="Panel" type="Panel" parent="."]
[node name="SearchPanel" type="Panel" parent="."]
unique_name_in_owner = true
layout_mode = 0
offset_right = 1152.0
offset_bottom = 640.0
@@ -30,7 +31,7 @@ text = "Clear"
[node name="CloseButton" type="Button" parent="."]
texture_filter = 1
layout_mode = 2
layout_mode = 0
offset_left = 1032.0
offset_top = 24.0
offset_right = 1082.0
@@ -51,7 +52,7 @@ scale = Vector2(2, 2)
placeholder_text = "Search"
[node name="ScrollContainer" type="ScrollContainer" parent="."]
layout_mode = 2
layout_mode = 0
offset_top = 128.0
offset_right = 576.0
offset_bottom = 384.0

View File

@@ -21,6 +21,7 @@ var play_local: bool = false
var player_array: Array[PlayerObject]
var edit_players: bool = false
var currently_syncing: bool = false
var character_select_open: bool = false
var version: String = "1.6.0"
@@ -28,6 +29,8 @@ var whats_new: String = "Changelog:
1.6.0:
#1: Fixed bug with inspiration list not reloading after sync
#2: New dialog for sync
#4: Now downloads characters from the server
#5: New character select screen
#6: Now show progress during sync
#7: Blocking all requests to the server during sync
#8: Added functionality to cache more than one song
@@ -76,7 +79,6 @@ func make_request2(address: String, func_name: Callable, expect_data: bool) -> v
elif func_name != null:
func_name.call(data_received)
else:
print("song_received")
print("data_received type: ", type_string(typeof(body)))
func_name.call(body)

View File

@@ -146,8 +146,5 @@ layout_mode = 2
text = "CatchedErrors"
horizontal_alignment = 1
[node name="CoolDownTimer" type="Timer" parent="."]
unique_name_in_owner = true
[node name="SyncTimer" type="Timer" parent="."]
unique_name_in_owner = true

46
character.gd Normal file
View File

@@ -0,0 +1,46 @@
class_name Character
extends Control
@onready
var panel: Panel = $Panel
@onready
var character_image: TextureRect = %CharacterTextureRect
@onready
var character_name_label: Label = %CharacterName
signal new_character_selected(img_texture: ImageTexture)
func set_character_name(character_name: String) -> void:
panel.size = Vector2(240, 145)
#margin.size = Vector2(240, 145)
#margin set margin 15, 10, 15, 0
character_name_label.text = character_name.split(".")[0]
character_name_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
var image_fetched: Callable = func image_fetched(image: PackedByteArray) -> void:
var img: Image = Image.new()
var err: Error = img.load_png_from_buffer(image)
if err != OK:
print(err)
var err2: Error = img.load_jpg_from_buffer(image)
if err2 != OK:
print(err2)
var new_image: ImageTexture = ImageTexture.new()
new_image.set_image(img)
character_image.custom_minimum_size = Vector2(200, 100)
character_image.size = Vector2(200, 100)
character_image.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
character_image.size_flags_vertical = Control.SIZE_SHRINK_CENTER
character_image.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL
character_image.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
character_image.texture = new_image
Settings.make_request2("/character?name=" + character_name.uri_encode(), image_fetched, true)
func _input(event: InputEvent) -> void:
if self.visible == true && Settings.character_select_open == true:
if event is InputEventMouseButton && event.is_pressed():
var evLocal: InputEvent = make_input_local(event)
if Rect2(Vector2(0, 0), panel.size).has_point(evLocal.position):
print(character_name_label.text)
new_character_selected.emit(character_image.texture)

1
character.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://i35b3scbpwpu

45
character.tscn Normal file
View File

@@ -0,0 +1,45 @@
[gd_scene load_steps=4 format=3 uid="uid://c7ecjj2af6usf"]
[ext_resource type="Script" uid="uid://i35b3scbpwpu" path="res://character.gd" id="1_pjt0s"]
[ext_resource type="Texture2D" uid="uid://cv3hdd6bsruau" path="res://icon.svg" id="2_pjt0s"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pjt0s"]
bg_color = Color(0.302, 0.302, 0.302, 1)
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_pjt0s")
[node name="Panel" type="Panel" parent="."]
layout_mode = 0
offset_right = 240.0
offset_bottom = 145.0
theme_override_styles/panel = SubResource("StyleBoxFlat_pjt0s")
[node name="MarginContainer" type="MarginContainer" parent="Panel"]
layout_mode = 0
offset_right = 240.0
offset_bottom = 145.0
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 15
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer"]
layout_mode = 2
[node name="CharacterTextureRect" type="TextureRect" parent="Panel/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(200, 100)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("2_pjt0s")
expand_mode = 3
stretch_mode = 5
[node name="CharacterName" type="Label" parent="Panel/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Aloy"
horizontal_alignment = 1

80
new_character_select.gd Normal file
View File

@@ -0,0 +1,80 @@
extends Control
@onready
var character_panel: Panel = %CharacterPanel
@onready
var character_grid: GridContainer = %CharacterGridContainer
@onready
var close_timer: Timer = %CloseTimer
signal character_selected(file_name: String)
signal new_new_character_selected(file_name: String)
var character: PackedScene = preload("res://character.tscn")
func _ready() -> void:
close_timer.timeout.connect(_on_close_timeout)
func select_character(file_name: String) -> void:
print("select_character")
character_selected.emit(file_name)
func _on_close_timeout() -> void:
print("_on_close_timeout!")
Settings.character_select_open = false
close_timer.stop()
func load_characters() -> void:
print("load_characters")
var fetch_character_list: Callable = func fetch_character_list(list) -> void:
print("fetch_character_list")
Settings.delete_children(character_grid)
if typeof(list) == TYPE_ARRAY:
for character_name: String in list:
print("character_name ", character_name)
var character_box: Character = character.instantiate()
character_grid.add_child(character_box)
character_box.custom_minimum_size = Vector2(235, 145)
character_box.size = Vector2(235, 145)
character_box.set_character_name(character_name)
character_box.connect("new_character_selected", _on_character_selected)
Settings.make_request2("/characters", fetch_character_list, true)
func show_grid() -> void:
print("show_grid")
self.visible = true
Settings.character_select_open = true
func _on_character_selected(texture: ImageTexture) -> void:
print("_on_character_selected")
self.visible = false
new_new_character_selected.emit(texture)
close_timer.start()
func _input(event: InputEvent) -> void:
if self.visible == true:
if event is InputEventMouseButton && event.is_pressed():
var evLocal: InputEvent = make_input_local(event)
if !Rect2(Vector2(0, 0), character_panel.size).has_point(evLocal.position):
self.visible = false
Settings.character_select_open = false
func load_characters_local() -> void:
var characters: DirAccess = DirAccess.open("res://characters/")
if characters:
characters.list_dir_begin()
var file_name: String = characters.get_next()
while file_name != "":
file_name = file_name.replace('.import', '') # <--- remove the .import
if file_name.ends_with(".png"):
var texture: Resource = load("res://characters/" + file_name)
var texture_btn: TextureButton = TextureButton.new()
character_grid.add_child(texture_btn)
texture_btn.custom_minimum_size = Vector2(80, 40)
texture_btn.ignore_texture_size = true
texture_btn.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT
texture_btn.texture_normal = texture
texture_btn.pressed.connect(select_character.bind(file_name))
file_name = characters.get_next()

View File

@@ -0,0 +1 @@
uid://cvffg87wr6r3y

55
new_character_select.tscn Normal file
View File

@@ -0,0 +1,55 @@
[gd_scene load_steps=3 format=3 uid="uid://cdy4kvemwaiom"]
[ext_resource type="Script" uid="uid://cvffg87wr6r3y" path="res://new_character_select.gd" id="1_h4tdp"]
[sub_resource type="LabelSettings" id="LabelSettings_p4iny"]
font_size = 25
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_h4tdp")
[node name="CharacterPanel" type="Panel" parent="."]
unique_name_in_owner = true
layout_mode = 0
offset_right = 1260.0
offset_bottom = 665.0
[node name="VBoxContainer" type="VBoxContainer" parent="CharacterPanel"]
layout_mode = 0
offset_right = 1263.0
offset_bottom = 659.0
size_flags_horizontal = 3
[node name="Label" type="Label" parent="CharacterPanel/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 0
text = "Character Select"
label_settings = SubResource("LabelSettings_p4iny")
horizontal_alignment = 1
[node name="MarginContainer" type="MarginContainer" parent="CharacterPanel/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 10
[node name="ScrollContainer" type="ScrollContainer" parent="CharacterPanel/VBoxContainer/MarginContainer"]
custom_minimum_size = Vector2(0, 600)
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="CharacterGridContainer" type="GridContainer" parent="CharacterPanel/VBoxContainer/MarginContainer/ScrollContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(1150, 600)
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/h_separation = 10
theme_override_constants/v_separation = 10
columns = 5
[node name="CloseTimer" type="Timer" parent="CharacterPanel"]
unique_name_in_owner = true

View File

@@ -44,7 +44,7 @@ func update_players() -> void:
if player.id == player_id:
var texture: TextureRect = TextureRect.new()
texture.texture = player.character
texture.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
texture.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL
texture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
texture.custom_minimum_size = Vector2(50, 25)
song_list_players.add_child(texture)

View File

@@ -54,22 +54,16 @@ var catched_errors_vbox: VBoxContainer = %CatchedErrorsVBox
@onready
var sync_time: Label = %SyncTime
@onready
var cool_down_timer: Timer = %CoolDownTimer
@onready
var sync_timer: Timer = %SyncTimer
var changes: bool = false
var cool_down_ongoing: bool = false
signal sync_started
signal sync_finished
func _ready() -> void:
sync_timer.timeout.connect(_on_sync_timeout)
cool_down_timer.timeout.connect(_on_cool_down_timeout)
func _input(event: InputEvent) -> void:
if self.visible == true:
@@ -86,14 +80,9 @@ func start_sync() -> void:
Settings.currently_syncing = true
sync_started.emit()
show_sync_progress()
if !cool_down_ongoing && !Settings.currently_syncing:
if !Settings.currently_syncing:
Settings.make_request2("/sync", sync_request_sent, false)
func _on_cool_down_timeout() -> void:
print("_on_cool_down_timeout")
print("COOLDOWN IS NOW FINSISHED, SYNC CAN START AGAIN")
cool_down_ongoing = false
func _on_sync_timeout() -> void:
print("_on_sync_timeout!")
var get_progress: Callable = func get_progress(data_received: Dictionary) -> void:
@@ -146,8 +135,6 @@ func on_sync_finished(data_received: Dictionary) -> void:
sync_timer.stop()
print("sync finished")
show_sync_result()
cool_down_timer.start(30*60)
cool_down_ongoing = true
sync_finished.emit()
func list_visible(vbox: VBoxContainer, seperator: VSeparator) -> void: