forked from team-sg/hero-mark-2
file select and file creation, menus glued together
This commit is contained in:
parent
13708b4046
commit
f7496c5e6f
18 changed files with 754 additions and 47 deletions
58
menus/file_create.gd
Normal file
58
menus/file_create.gd
Normal file
|
@ -0,0 +1,58 @@
|
|||
extends Node
|
||||
|
||||
|
||||
var file: Save.SaveFile = null
|
||||
var difficulty: int = Game.Difficulty.SPICY
|
||||
|
||||
onready var face: Sprite = $"%Face"
|
||||
onready var chosen_name: Label = $"%ChosenName"
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# escape to file select if no file is assigned
|
||||
if not file:
|
||||
yield(get_tree(), "idle_frame")
|
||||
SceneManager.current_scene = load("res://menus/file_select.tscn").instance()
|
||||
return
|
||||
|
||||
# pause so that player can not move around until difficulty chosen
|
||||
get_tree().paused = true
|
||||
# initialize name
|
||||
chosen_name.text = ""
|
||||
file.name = ""
|
||||
# fade in
|
||||
Fade.fade_in(0.4)
|
||||
# focus the difficulty
|
||||
$"%Spicy".call_deferred("grab_focus")
|
||||
|
||||
|
||||
func _set_difficulty(value: int) -> void:
|
||||
difficulty = posmod(value, 4)
|
||||
file.difficulty = difficulty
|
||||
face.frame = difficulty
|
||||
|
||||
|
||||
func _difficulty_selected() -> void:
|
||||
Fade.fade_out(0.4)
|
||||
yield(Fade, "fade_finished")
|
||||
$"%DifficultySelect".queue_free()
|
||||
$"%NameEntry".visible = true
|
||||
get_tree().paused = false
|
||||
Game.use_lives = false
|
||||
Fade.fade_in(0.4)
|
||||
|
||||
func _on_letter_chosen(letter: String) -> void:
|
||||
file.name += letter
|
||||
chosen_name.text = file.name
|
||||
if file.name.length() > 0:
|
||||
$"%ExitDoor".frame = 1
|
||||
|
||||
|
||||
func _on_Exit_area_entered(area: Area2D) -> void:
|
||||
if file.name.length() > 0:
|
||||
get_tree().paused = true
|
||||
file.save_to_file()
|
||||
Fade.fade_out(0.4)
|
||||
yield(Fade, "fade_finished")
|
||||
get_tree().paused = false
|
||||
SceneManager.current_scene = load("res://menus/file_select.tscn").instance()
|
Loading…
Add table
Add a link
Reference in a new issue