hero-mark-2/objects/hud/options_screen_scholar.gd

134 lines
3.7 KiB
GDScript

extends Control
signal exit
# if true, options screen can not exit
var can_exit: bool = true
onready var tabs: TabContainer = $"%Tabs"
onready var select_tab: HBoxContainer = $"%SelectTab"
# options nodes
onready var rumble: HBoxContainer = $"%SelectRumble"
onready var gore: HBoxContainer = $"%SelectGore"
onready var speedrun_timer: HBoxContainer = $"%SelectSpeedrunTimer"
onready var speccy_help: HBoxContainer = $"%SelectSpeccyHelp"
onready var fullscreen: HBoxContainer = $"%SelectFullscreen"
onready var window_size: HBoxContainer = $"%SelectWindowSize"
onready var scaling: HBoxContainer = $"%SelectScaling"
onready var fade_speed: HBoxContainer = $"%SelectFadeSpeed"
onready var border: Button = $"%SelectBorder"
onready var scanlines: HBoxContainer = $"%SelectScanlines"
onready var master_vol: HSlider = $"%SelectMasterVol"
onready var music_vol: HSlider = $"%SelectMusicVol"
onready var sound_vol: HSlider = $"%SelectSoundVol"
onready var landing_sound: HBoxContainer = $"%SelectLandingSound"
func _ready() -> void:
get_scene_instance_load_placeholder()
_init_values()
func focus() -> void:
select_tab.selection = 0
$"%SelectTab".grab_focus()
_on_tab_selected(0)
func _unhandled_input(event: InputEvent) -> void:
Options.save_options()
if can_exit and event.is_action_pressed("ui_cancel") and not Options.entry:
if visible == true: emit_signal("exit")
func _init_values() -> void:
# game
rumble.selection = Options.rumble
gore.selection = Options.gore
speedrun_timer.selection = 1 if Options.speedrun_timer else 0
speccy_help.selection = 1 if Options.speccy_help else 0
# video
fullscreen.selection = 1 if Options.fullscreen else 0
window_size.selection = int(Options.window_size) - 1
scaling.selection = Options.scaling_mode
fade_speed.selection = Options.transition_speed
border._update()
scanlines.selection = Options.scanlines
# audio
master_vol.value = Options.master_volume * 100.0
music_vol.value = Options.music_volume * 100.0
sound_vol.value = Options.sound_volume * 100.0
landing_sound.selection = 1 if Options.landing_sound else 0
func _on_tab_selected(selection: int) -> void:
tabs.current_tab = selection
var tab = tabs.get_current_tab_control()
var next = tab.get_node(tab.focus_next)
if next:
select_tab.focus_neighbour_bottom = select_tab.get_path_to(next)
else:
select_tab.focus_neighbour_bottom = @"."
select_tab.update_focus_targets()
#
# GAME
#
func _on_Rumble_selected(selection) -> void:
Options.rumble = selection
func _on_Gore_selected(selection) -> void:
Options.gore = selection
func _on_SelectSpeedrunTimer_selected(selection) -> void:
Options.speedrun_timer = selection == 1
func _on_SelectSpeccyHelp_selected(selection) -> void:
Options.speccy_help = selection == 1
#
# VIDEO
#
func _on_Fullscreen_selected(selection) -> void:
Options.fullscreen = selection == 1 # true if 1, false otherwise
func _on_WindowSize_selected(selection) -> void:
Options.window_size = float(selection + 1)
func _on_Scaling_selected(selection) -> void:
Options.scaling_mode = selection
func _on_FadeSpeed_selected(selection) -> void:
Options.transition_speed = selection
func _on_Border_selected(selection) -> void:
Options.border = selection
func _on_Scanlines_selected(selection) -> void:
Options.scanlines = selection
#
# AUDIO
#
func _on_MasterVol_value_changed(value: float) -> void:
Options.master_volume = value * 0.01
func _on_MusicVol_value_changed(value: float) -> void:
Options.music_volume = value * 0.01
func _on_SoundVol_value_changed(value: float) -> void:
Options.sound_volume = value * 0.01
func _on_LandingSound_selected(selection) -> void:
Options.landing_sound = selection == 1
func _on_DefaultControls_button_down() -> void:
Controls.default_controls()