Popups: - All nine popups now extend a shared PopupWindow class with open(), close() and toggle(), instead of each copying its own close-on-click code. Popups that need cleanup override close(). - A click outside a popup closed it and also pressed whatever was underneath, e.g. Reset playlist. The closing click is now consumed. - Popups used Godot's see-through default panel, so the song list and titles showed through. They now use an opaque popup theme, and a backdrop dims the window behind them. - The main window root now fills the screen, so the backdrop covers it. Text and images: - Many labels and buttons forced nearest filtering, which made text and icons jagged when the window is not 1920x1080. They now use the default smooth filtering. Only the pixel-art "no character" picture keeps nearest filtering when the winner window enlarges it. Player list: - A long player name pushed that row's character and buttons to the right. Names now take the free space and shorten with an ellipsis, so all rows line up and use the full width of the panel.
66 lines
2.0 KiB
GDScript
66 lines
2.0 KiB
GDScript
extends PopupWindow
|
|
|
|
@onready
|
|
var character_panel: Panel = %CharacterPanel
|
|
|
|
@onready
|
|
var title_label: Label = %TitleLabel
|
|
|
|
@onready
|
|
var character_grid: GridContainer = %CharacterGridContainer
|
|
|
|
@onready
|
|
var close_timer: Timer = %CloseTimer
|
|
|
|
var can_select_character: bool = false
|
|
|
|
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 _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)
|
|
MusicServerClient.fetch_character_list(fetch_character_list)
|
|
|
|
func show_grid(player_name: String) -> void:
|
|
print("show_grid")
|
|
title_label.text = "Select character for " + player_name
|
|
close_timer.stop()
|
|
open()
|
|
can_select_character = true
|
|
Settings.character_select_open = true
|
|
|
|
func close() -> void:
|
|
super()
|
|
Settings.character_select_open = false
|
|
|
|
func _on_character_selected(texture: ImageTexture) -> void:
|
|
print("_on_character_selected")
|
|
# Not close(): character_select_open stays true until close_timer fires, so the click
|
|
# that picked the character does not also select a song behind it
|
|
self.visible = false
|
|
if can_select_character:
|
|
new_new_character_selected.emit(texture)
|
|
close_timer.start()
|
|
can_select_character = false
|