Follow the GDScript style guide in every script
- Types on every parameter, return value and variable, and snake_case names (the player name limit is the constant MAX_NAME_LENGTH). - Spelling fixes: *_triggered, character_selected, separator, caught_errors. The server's catched_errors key stays as the server sends it. - Signals are connected with signal.connect() instead of by name. - Code is ordered signals, constants, exported vars, vars, @onready vars, functions, with @onready on one line and two blank lines between functions. - Every script starts with a ## description. Template comments, old LOC notes and commented-out code are gone, apart from the local play code. - Lines are at most 100 characters, apart from the local play path. - The screenshot tour turns off the blinking text cursor so pictures match.
This commit is contained in:
1 parent
674604425f
commit
a0428e3475
45 files changed
+580
-589
No files matched your search
+17
-18
@@ -1,35 +1,31 @@
|
||||
class_name CharacterSelectPopup
|
||||
extends BasePopup
|
||||
|
||||
@onready
|
||||
var character_panel: Panel = %CharacterPanel
|
||||
|
||||
@onready
|
||||
var title_label: Label = %TitleLabel
|
||||
|
||||
@onready
|
||||
var character_grid: GridContainer = %CharacterGridContainer
|
||||
|
||||
@onready
|
||||
var close_timer: Timer = %CloseTimer
|
||||
## Emitted with the picture of the character that was picked.
|
||||
signal character_selected(texture: ImageTexture)
|
||||
|
||||
var can_select_character: bool = false
|
||||
|
||||
signal new_new_character_selected(file_name: String)
|
||||
|
||||
var character: PackedScene = preload("res://CharacterCard.tscn")
|
||||
|
||||
@onready var character_panel: Panel = %CharacterPanel
|
||||
@onready var title_label: Label = %TitleLabel
|
||||
@onready var character_grid: GridContainer = %CharacterGridContainer
|
||||
@onready var close_timer: Timer = %CloseTimer
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
close_timer.timeout.connect(_on_close_timeout)
|
||||
|
||||
|
||||
func _on_close_timeout() -> void:
|
||||
GameLog.debug("_on_close_timeout!")
|
||||
Settings.character_select_open = false
|
||||
close_timer.stop()
|
||||
|
||||
|
||||
func load_characters() -> void:
|
||||
GameLog.debug("load_characters")
|
||||
var fetch_character_list: Callable = func fetch_character_list(list) -> void:
|
||||
var fetch_character_list: Callable = func fetch_character_list(list: Variant) -> void:
|
||||
GameLog.debug("fetch_character_list")
|
||||
Settings.delete_children(character_grid)
|
||||
if typeof(list) == TYPE_ARRAY:
|
||||
@@ -40,9 +36,10 @@ func load_characters() -> void:
|
||||
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)
|
||||
character_box.new_character_selected.connect(_on_character_selected)
|
||||
MusicServerClient.fetch_character_list(fetch_character_list)
|
||||
|
||||
|
||||
func show_grid(player_name: String) -> void:
|
||||
GameLog.debug("show_grid")
|
||||
title_label.text = "Select character for " + player_name
|
||||
@@ -51,16 +48,18 @@ func show_grid(player_name: String) -> void:
|
||||
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:
|
||||
GameLog.debug("_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
|
||||
visible = false
|
||||
if can_select_character:
|
||||
new_new_character_selected.emit(texture)
|
||||
character_selected.emit(texture)
|
||||
close_timer.start()
|
||||
can_select_character = false
|
||||
Reference in new issue
Block a user