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
+19
-19
@@ -1,21 +1,6 @@
|
||||
class_name PlayerRow
|
||||
extends Control
|
||||
|
||||
@onready
|
||||
var player_name_field: Label = %Name
|
||||
|
||||
@onready
|
||||
var add_button: Button = %AddPoint
|
||||
|
||||
@onready
|
||||
var minus_button: Button = %RemovePoint
|
||||
|
||||
@onready
|
||||
var character: TextureButton = %Character
|
||||
|
||||
@onready
|
||||
var remove_player: TextureButton = %RemovePlayer
|
||||
|
||||
signal change_character_clicked
|
||||
signal player_removed
|
||||
|
||||
@@ -26,7 +11,13 @@ var player_object: PlayerObject
|
||||
## gives this player a point and Ctrl+Alt+<list_index + 1> takes one away.
|
||||
var list_index: int
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
@onready var player_name_field: Label = %Name
|
||||
@onready var add_button: Button = %AddPoint
|
||||
@onready var minus_button: Button = %RemovePoint
|
||||
@onready var character: TextureButton = %Character
|
||||
@onready var remove_player: TextureButton = %RemovePlayer
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
add_button.pressed.connect(add_point)
|
||||
add_button.set_shortcut(create_button_shortcut(list_index, false))
|
||||
@@ -37,42 +28,51 @@ func _ready() -> void:
|
||||
update_score()
|
||||
set_player_character()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
remove_player.visible = Settings.edit_players
|
||||
|
||||
|
||||
func create_button_shortcut(index: int, ctrl_pressed: bool) -> Shortcut:
|
||||
var button_shortcut: Shortcut = Shortcut.new()
|
||||
var button_event : InputEventKey = InputEventKey.new()
|
||||
var button_event: InputEventKey = InputEventKey.new()
|
||||
button_event.keycode = KEY_1 + index
|
||||
button_event.alt_pressed = true
|
||||
button_event.ctrl_pressed = ctrl_pressed
|
||||
button_shortcut.events.append(button_event)
|
||||
return button_shortcut
|
||||
|
||||
|
||||
func add_point() -> void:
|
||||
player_object.add_point()
|
||||
update_score()
|
||||
|
||||
|
||||
func minus_point() -> void:
|
||||
player_object.minus_point()
|
||||
update_score()
|
||||
|
||||
|
||||
|
||||
func change_character() -> void:
|
||||
change_character_clicked.emit()
|
||||
|
||||
|
||||
func new_character_selected(character_texture: ImageTexture) -> void:
|
||||
GameLog.debug("Back in player list with new")
|
||||
player_object.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_CENTERED
|
||||
character.texture_normal = player_object.character
|
||||
|
||||
|
||||
func update_score() -> void:
|
||||
if OS.has_feature("debug"):
|
||||
player_name_field.text = str(list_index + 1) + " " + player_object.player_name + ": " + str(player_object.player_score)
|
||||
player_name_field.text = "%d %s: %d" % [list_index + 1, player_object.player_name,
|
||||
player_object.player_score]
|
||||
else:
|
||||
player_name_field.text = player_object.player_name + ": " + str(player_object.player_score)
|
||||
Reference in new issue
Block a user