stick-the-quick/ui/MainMenu/TopLevel/MainMenu_TopLevel.gd

196 lines
6.0 KiB
GDScript3
Raw Normal View History

class_name MainMenu_TopLevel extends Control
@onready var buttons := $'PanelContainer/HBoxContainer/Buttons'
@onready var story_button := (
buttons.get_node(^'StoryButton')
) as TextureButton
@onready var options_button := (
buttons.get_node(^'OptionsButton')
) as TextureButton
@onready var mission_button := (
buttons.get_node(^'MissionButton')
) as TextureButton
@onready var freerun_button := (
buttons.get_node(^'FreerunButton')
) as TextureButton
@onready var about_button := (
buttons.get_node(^'AboutButton')
) as TextureButton
@onready var quit_button := (
buttons.get_node(^'QuitButton')
) as TextureButton
@onready var hour_hand := (
buttons.get_node(^'HourHand')
) as Control
@onready var minute_hand := (
buttons.get_node(^'MinuteHand')
) as Control
@onready var info_mode_name := (
$PanelContainer/HBoxContainer/Info/MarginContainer/VBoxContainer/ModeName
) as Label
@onready var info_screenshot := (
$PanelContainer/HBoxContainer/Info/MarginContainer/VBoxContainer/Screenshot
) as TextureRect
@onready var info_mode_description := (
$PanelContainer/HBoxContainer/Info/MarginContainer/VBoxContainer\
/Description
) as Label
func _ready() -> void:
var args := UI.Args(self)
args.on_cancel = _on_cancel
story_button.pressed.connect(_on_story_button)
options_button.pressed.connect(_on_options_button)
mission_button.pressed.connect(_on_mission_button)
freerun_button.pressed.connect(_on_freerun_button)
about_button.pressed.connect(_on_about_button)
quit_button.pressed.connect(_on_quit_button)
buttons.focus_entered.connect(_show_info_generic)
story_button.mouse_entered.connect(_show_info_story)
story_button.focus_entered.connect(_show_info_story)
options_button.mouse_entered.connect(_show_info_options)
options_button.focus_entered.connect(_show_info_options)
mission_button.mouse_entered.connect(_show_info_mission)
mission_button.focus_entered.connect(_show_info_mission)
freerun_button.mouse_entered.connect(_show_info_freerun)
freerun_button.focus_entered.connect(_show_info_freerun)
about_button.mouse_entered.connect(_show_info_about)
about_button.focus_entered.connect(_show_info_about)
quit_button.mouse_entered.connect(_show_info_quit)
quit_button.focus_entered.connect(_show_info_quit)
_show_info_generic()
_initialize_clock_hands.call_deferred()
func _initialize_clock_hands() -> void:
minute_hand.pivot_offset.x = minute_hand.size.x*0.375
hour_hand.pivot_offset.x = hour_hand.size.x*0.375
minute_hand.pivot_offset.y = minute_hand.size.y*0.5
hour_hand.pivot_offset.y = hour_hand.size.y*0.5
func _process(delta: float) -> void:
var focused := get_viewport().gui_get_focus_owner()
match focused:
story_button:
minute_hand.rotation = lerp(minute_hand.rotation, TAU*0.4, delta)
hour_hand.rotation = lerp(hour_hand.rotation, TAU*0.6, delta)
options_button:
minute_hand.rotation = lerp(minute_hand.rotation, TAU*0.9, delta)
hour_hand.rotation = lerp(hour_hand.rotation, TAU*0.7, delta)
mission_button:
minute_hand.rotation = lerp(minute_hand.rotation, TAU*0.1, delta)
hour_hand.rotation = lerp(hour_hand.rotation, TAU*0.9, delta)
freerun_button:
minute_hand.rotation = lerp(minute_hand.rotation, TAU*0.3, delta)
hour_hand.rotation = lerp(hour_hand.rotation, TAU*0.1, delta)
_:
minute_hand.rotation = fposmod(
minute_hand.rotation - delta*PI, TAU
)
hour_hand.rotation = fposmod(
hour_hand.rotation + delta*PI/60.0, TAU
)
func _on_story_button() -> void:
var params = await UI.Call(load(
"res://ui/MainMenu/CharacterSelect/MainMenu_CharacterSelect.tscn"
), {
&'mode': &'story'
})
if params:
print(params)
UI.Return(self, params)
func _on_options_button() -> void:
UI.Call(load("res://ui/MainMenu/Options/MainMenu_Options.tscn"))
func _on_mission_button() -> void:
var params = await UI.Call(load(
"res://ui/MainMenu/CharacterSelect/MainMenu_CharacterSelect.tscn"
), {
&'mode': &'mission'
})
if params:
UI.Return(self, params)
func _on_freerun_button() -> void:
var params = await UI.Call(load(
"res://ui/MainMenu/CharacterSelect/MainMenu_CharacterSelect.tscn"
), {
&'mode': &'freerun'
})
if params:
UI.Return(self, params)
func _on_about_button() -> void:
UI.Call(load("res://ui/MainMenu/About/MainMenu_About.tscn"))
func _on_quit_button() -> void:
await FX.fade(Color.BLACK)
get_tree().quit()
func _on_cancel() -> void:
buttons.grab_focus()
func _show_info_generic() -> void:
if Storyboard.save_data_exists():
info_mode_name.text = "Save data"
info_screenshot.texture = null # TODO
info_mode_description.text = ((
"Play time: %s\n" +
"Ico'z snagged: %d\n"
) % [
TimeIntervalFormatting.format_systime_interval(
Storyboard.get_play_time()
),
Storyboard.count_cleared_missions()
])
else:
info_mode_name.text = "Welcome!"
info_screenshot.texture = null # TODO
info_mode_description.text = ""
func _show_info_story() -> void:
info_mode_name.text = "Story mode"
info_screenshot.texture = null # TODO
info_mode_description.text = (
"Play through the game's story in sequential order."
)
func _show_info_options() -> void:
info_mode_name.text = "Options"
info_screenshot.texture = null # TODO
info_mode_description.text = (
"Configure the game's behavior as an application."
)
func _show_info_mission() -> void:
info_mode_name.text = "Mission mode"
info_screenshot.texture = null # TODO
info_mode_description.text = (
"Return to missions you've cleared in story mode " +
"and replay them for a better clear time."
)
func _show_info_freerun() -> void:
info_mode_name.text = "Freerun"
info_screenshot.texture = null # TODO
info_mode_description.text = (
"If you've cleared at least one mission in a level, " +
"you can return to that level and play it " +
"as a sandbox with no objective."
)
func _show_info_about() -> void:
info_mode_name.text = "About"
info_screenshot.texture = null # TODO
info_mode_description.text = (
"View license agreement and/or credits."
)
func _show_info_quit() -> void:
info_mode_name.text = "Quit"
info_screenshot.texture = null # TODO
info_mode_description.text = (
"Exit the game."
)