forked from team-sg/hero-mark-2
69 lines
1.8 KiB
GDScript
69 lines
1.8 KiB
GDScript
extends Node
|
|
|
|
|
|
enum Completion {ANY, FULL}
|
|
enum ScoreType {SCORE, TIME}
|
|
|
|
|
|
const COMPLETION_NAMES = ["Any%", "100%"]
|
|
const SCORE_TYPE_NAMES = ["Scores", "Times"]
|
|
|
|
|
|
var selected_difficulty: int = Game.Difficulty.SPICY
|
|
var selected_completion: int = Completion.ANY
|
|
var selected_type: int = ScoreType.SCORE
|
|
|
|
|
|
onready var level_title: Button = $"%LevelTitle"
|
|
onready var back_arrow: TextureRect = $"%BackArrow"
|
|
onready var next_arrow: TextureRect = $"%NextArrow"
|
|
onready var difficulty: Button = $"%Difficulty"
|
|
onready var completion: Button = $"%Completion"
|
|
onready var type: Button = $"%Type"
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
yield(get_tree(), "idle_frame")
|
|
level_title.grab_focus()
|
|
|
|
|
|
# reload scores from newgrounds
|
|
func reload_scores() -> void:
|
|
pass
|
|
|
|
|
|
# show arrows when level is focused
|
|
func _on_LevelTitle_focus_entered() -> void:
|
|
back_arrow.visible = true
|
|
next_arrow.visible = true
|
|
|
|
# hide arrows when level not focused
|
|
func _on_LevelTitle_focus_exited() -> void:
|
|
back_arrow.visible = false
|
|
next_arrow.visible = false
|
|
|
|
# detect left and right presses when level is focused
|
|
func _on_LevelTitle_gui_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("ui_left"):
|
|
print("PREV")
|
|
elif event.is_action_pressed("ui_right"):
|
|
print("NEXT")
|
|
|
|
# difficulty selector
|
|
func _on_Difficulty_pressed() -> void:
|
|
selected_difficulty = posmod(selected_difficulty + 1, 4)
|
|
difficulty.text = Game.DIFFICULTY_NAMES[selected_difficulty]
|
|
reload_scores()
|
|
|
|
# completion amount selector
|
|
func _on_Completion_pressed() -> void:
|
|
selected_completion = posmod(selected_completion + 1, 2)
|
|
completion.text = COMPLETION_NAMES[selected_completion]
|
|
reload_scores()
|
|
|
|
# score type selector
|
|
func _on_Type_pressed() -> void:
|
|
selected_type = posmod(selected_type + 1, 2)
|
|
type.text = SCORE_TYPE_NAMES[selected_type]
|
|
reload_scores()
|