46 lines
1011 B
GDScript
46 lines
1011 B
GDScript
extends Control
|
|
|
|
signal exit
|
|
|
|
var profile: Profile = Profile.new("profile")
|
|
@onready var next: Button = $VBoxContainer/HBoxContainer/Next
|
|
@onready var line_edit: LineEdit = $VBoxContainer/LineEdit
|
|
|
|
@onready var max_index: int = profile.named_things.keys().size() - 1
|
|
var index: int = 0
|
|
|
|
func _ready() -> void:
|
|
next.disabled = index == max_index
|
|
|
|
func _on_back_button_pressed() -> void:
|
|
if index == 0:
|
|
exit.emit()
|
|
else:
|
|
index -= 1
|
|
update_name()
|
|
|
|
func _on_next_pressed() -> void:
|
|
index += 1
|
|
update_name()
|
|
|
|
func update_name() -> void:
|
|
if index == max_index:
|
|
next.text = "Finish"
|
|
elif index > max_index:
|
|
profile.save()
|
|
EventManager.run_event(EventManager.Events.PUMPKIN_CARVE)
|
|
return
|
|
else:
|
|
next.text = "Next"
|
|
|
|
var labels: Dictionary = {
|
|
"player_name": "Name him",
|
|
"villain_friend": "Name him too",
|
|
"stupid_friend": "And also name him",
|
|
"favourite_candy": "Favourite candy?"
|
|
}
|
|
|
|
var label: String = labels[profile.named_things.keys()[index]]
|
|
line_edit.placeholder_text = label
|
|
|