Yahtzee/MainMenu.gd
Yadciel 50e777a6fa Apply theme to OptionButtons in GameScene
Added a new theme resource for OptionButtons to ensure consistent font sizes. Updated MainMenu text to correctly number new players without adding one.
2024-08-19 22:46:52 +02:00

51 lines
1.5 KiB
GDScript

extends Control
var PlayerList : VBoxContainer
var PlayerPanel : PackedScene
var GameScene
# Called when the node enters the scene tree for the first time.
func _ready():
PlayerList = get_node("ScrollContainer/VBoxContainer")
PlayerPanel = load("res://PlayerPanel.tscn")
GameScene = preload("res://GameScene.tscn").instantiate()
Player_Manger.clear_players()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_button_pressed():
var player = PlayerPanel.instantiate()
var player_name : TextEdit = player.get_child(0)
if player_name != null:
player_name.text = "Player " + str(PlayerList.get_child_count())
player_name.connect("text_changed", Callable(self, "_on_text_changed"))
PlayerList.add_child(player)
else:
print("Error: player_name is null")
pass # Replace with function body.
func _on_text_changed():
var players = PlayerList.get_children()
for player in players:
var player_name : TextEdit = player.get_child(0)
if player_name != null and player_name.text == "":
return
pass # Replace with function body.
func _on_button_play_pressed():
var players = PlayerList.get_children()
for player in players:
var player_name : TextEdit = player.get_child(0)
if player_name != null:
var player_instance = Player.new(player_name.text)
Player_Manger.add_player(player_instance)
else:
print("Error: player_name is null")
get_tree().change_scene_to_file("res://GameScene.tscn")
pass # Replace with function body.