2018-07-25 07:36:19 +00:00
|
|
|
extends MarginContainer
|
|
|
|
|
|
|
|
var HUD_config_file = "user://hud.cfg"
|
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
var config_file = ConfigFile.new()
|
|
|
|
var err = config_file.load( HUD_config_file )
|
|
|
|
if err:
|
|
|
|
print("Error code when loading config file: ", err)
|
|
|
|
else:
|
|
|
|
for child in get_node("Windows" ).get_children():
|
|
|
|
child.load_from_file( config_file )
|
|
|
|
|
|
|
|
func _input( event ):
|
|
|
|
if event.is_action_pressed( "ui_music_controls" ):
|
|
|
|
$Windows/Music.visible = not $Windows/Music.visible
|
|
|
|
|
|
|
|
|
|
|
|
func _on_SaveHUD_pressed():
|
|
|
|
|
|
|
|
var config_file = ConfigFile.new()
|
|
|
|
var err = config_file.load( HUD_config_file )
|
|
|
|
if err:
|
|
|
|
print("Error code when loading config file: ", err)
|
|
|
|
|
|
|
|
for child in get_node("Windows" ).get_children():
|
|
|
|
child.save_to_file( config_file )
|
|
|
|
|
2018-07-27 14:13:54 +00:00
|
|
|
config_file.save( HUD_config_file )
|
|
|
|
|
|
|
|
func _on_Windows_gui_input( event ):
|
2018-07-28 18:34:08 +00:00
|
|
|
if event is InputEventMouseButton \
|
|
|
|
and event.button_index == BUTTON_LEFT \
|
|
|
|
and Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE \
|
|
|
|
and not event.is_echo() \
|
|
|
|
and not event.pressed:
|
|
|
|
Input.set_mouse_mode( Input.MOUSE_MODE_CAPTURED )
|
|
|
|
|
|
|
|
elif event is InputEventMouseButton \
|
|
|
|
and event.button_index == BUTTON_RIGHT \
|
|
|
|
and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED \
|
|
|
|
and not event.is_echo() \
|
|
|
|
and not event.pressed:
|
|
|
|
Input.set_mouse_mode( Input.MOUSE_MODE_VISIBLE )
|