forked from team-sg/hero-mark-2
options screen functionality :):):):):)
This commit is contained in:
parent
89b4bc045e
commit
1fc44271f1
10 changed files with 271 additions and 36 deletions
|
@ -1,13 +1,63 @@
|
|||
extends Control
|
||||
|
||||
# emmitted when "back" is pressed
|
||||
signal exit
|
||||
|
||||
export (StyleBox) var tab_selected_style
|
||||
|
||||
onready var tabs = $Tabs
|
||||
onready var confirm_dialog = $ConfirmDialog
|
||||
|
||||
# option controls #
|
||||
# game
|
||||
onready var rumble = $"%Rumble"
|
||||
# video
|
||||
onready var fullscreen = $"%Fullscreen"
|
||||
onready var window_size = $"%WindowSize"
|
||||
onready var scaling_mode = $"%ScalingMode"
|
||||
onready var transition_speed = $"%TransitionSpeed"
|
||||
# audio
|
||||
onready var master_volume = $"%MasterSlider"
|
||||
onready var music_volume = $"%MusicSlider"
|
||||
onready var sound_volume = $"%SoundSlider"
|
||||
|
||||
# flagged when options have been changed
|
||||
var dirty = false
|
||||
|
||||
func focus():
|
||||
load_options(Options)
|
||||
dirty = false
|
||||
visible = true
|
||||
confirm_dialog.visible = false
|
||||
grab_focus()
|
||||
|
||||
func load_options(options):
|
||||
# game
|
||||
rumble.select(options.rumble)
|
||||
# video
|
||||
fullscreen.select(1 if options.fullscreen else 0) # index 1 is the "on" button
|
||||
# window_size.select(options.window_size)
|
||||
scaling_mode.select(options.scaling_mode)
|
||||
transition_speed.select(options.transition_speed)
|
||||
# audio
|
||||
master_volume.value = options.master_volume
|
||||
music_volume.value = options.music_volume
|
||||
sound_volume.value = options.sound_volume
|
||||
|
||||
func apply_options():
|
||||
# game
|
||||
Options.rumble = rumble.get_selection()
|
||||
# video
|
||||
Options.fullscreen = fullscreen.get_selection() == 1 # true if 1, otherwise false
|
||||
# Options.window_size = window_size.get_selection()
|
||||
Options.scaling_mode = scaling_mode.get_selection()
|
||||
Options.transition_speed = transition_speed.get_selection()
|
||||
# audio
|
||||
Options.master_volume = master_volume.value
|
||||
Options.music_volume = music_volume.value
|
||||
Options.sound_volume = sound_volume.value
|
||||
print(Options.master_volume)
|
||||
|
||||
func _gui_input(event):
|
||||
if event.is_action_pressed("ui_left"):
|
||||
tabs.current_tab = posmod(tabs.current_tab - 1, tabs.get_child_count())
|
||||
|
@ -18,10 +68,35 @@ func _gui_input(event):
|
|||
current_tab.get_node(current_tab.focus_neighbour_bottom).grab_focus()
|
||||
accept_event()
|
||||
|
||||
func _physics_process(delta):
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
apply_options()
|
||||
elif Input.is_action_just_pressed("ui_cancel"):
|
||||
if dirty:
|
||||
confirm_dialog.visible = true
|
||||
confirm_dialog.grab_focus()
|
||||
else:
|
||||
emit_signal("exit")
|
||||
elif Input.is_action_just_pressed("ui_reset"):
|
||||
load_options(Options.defaults)
|
||||
dirty = true
|
||||
|
||||
# "_unused" is a dirty hack,
|
||||
# but it means we can connect signals that provide parameters
|
||||
func _mark_dirty(_unused = null, _unused2 = null):
|
||||
dirty = true
|
||||
|
||||
func _on_ConfirmDialog_gui_input(event):
|
||||
if event.is_action_pressed("ui_accept"):
|
||||
apply_options()
|
||||
confirm_dialog.visible = false
|
||||
emit_signal("exit")
|
||||
elif event.is_action_pressed("ui_cancel"):
|
||||
confirm_dialog.visible = false
|
||||
emit_signal("exit")
|
||||
|
||||
func _on_tabs_focus_entered():
|
||||
tabs.set("custom_styles/tab_fg", tab_selected_style)
|
||||
|
||||
|
||||
func _on_tabs_focus_exited():
|
||||
tabs.set("custom_styles/tab_fg", null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue