adding debug message
This commit is contained in:
parent
948f45bade
commit
e7ba3d0d56
5 changed files with 46 additions and 46 deletions
|
@ -16,7 +16,7 @@ func _ready():
|
|||
action_name = self.name
|
||||
current_keyboard = $keyboard
|
||||
load_from_config()
|
||||
|
||||
|
||||
var key_found = false
|
||||
var key_alt_found = false
|
||||
for event in InputMap.get_action_list( action_name ):
|
||||
|
@ -30,14 +30,14 @@ func _ready():
|
|||
key_alt_found = true
|
||||
elif event is InputEventJoypadButton:
|
||||
$joypad.text = Input.get_joy_button_string( event.button_index )
|
||||
|
||||
|
||||
$keyboard.connect( "pressed", self, "wait_for_input" )
|
||||
$keyboard_alt.connect( "pressed", self, "wait_for_input_alt" )
|
||||
$joypad.connect( "pressed", self, "wait_for_input" )
|
||||
|
||||
|
||||
set_process_input(false)
|
||||
func _enter_tree():
|
||||
|
||||
|
||||
if not self.has_node( "description" ):
|
||||
var new_label = Label.new()
|
||||
new_label.name = "description"
|
||||
|
@ -46,7 +46,7 @@ func _enter_tree():
|
|||
new_label.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
new_label.size_flags_vertical = SIZE_EXPAND
|
||||
self.add_child( new_label )
|
||||
new_label.set_owner( self )
|
||||
new_label.set_owner( self )
|
||||
|
||||
if not self.has_node( "keyboard" ):
|
||||
var new_button = Button.new()
|
||||
|
@ -55,7 +55,7 @@ func _enter_tree():
|
|||
new_button.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
new_button.size_flags_vertical = SIZE_EXPAND
|
||||
self.add_child( new_button )
|
||||
new_button.set_owner( self )
|
||||
new_button.set_owner( self )
|
||||
|
||||
if not self.has_node( "keyboard_alt" ):
|
||||
var new_button = Button.new()
|
||||
|
@ -64,7 +64,7 @@ func _enter_tree():
|
|||
new_button.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
new_button.size_flags_vertical = SIZE_EXPAND
|
||||
self.add_child( new_button )
|
||||
new_button.set_owner( self )
|
||||
new_button.set_owner( self )
|
||||
#
|
||||
#
|
||||
if not self.has_node( "joypad" ):
|
||||
|
@ -74,8 +74,8 @@ func _enter_tree():
|
|||
new_button_joypad.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
new_button_joypad.size_flags_vertical = SIZE_EXPAND
|
||||
self.add_child( new_button_joypad )
|
||||
new_button_joypad.set_owner( self )
|
||||
|
||||
new_button_joypad.set_owner( self )
|
||||
|
||||
func get_event_with_modifier_from_string( scancode, type ):
|
||||
if type == "keyboard":
|
||||
var new_event = InputEventKey.new()
|
||||
|
@ -94,28 +94,28 @@ func get_event_with_modifier_from_string( scancode, type ):
|
|||
|
||||
new_event.scancode = OS.find_scancode_from_string( scancode )
|
||||
return new_event
|
||||
elif type == "joypad":
|
||||
elif type == "joypad":
|
||||
var new_event = InputEventJoypadButton.new()
|
||||
|
||||
new_event.button_index = Input.get_joy_button_index_from_string( scancode )
|
||||
return new_event
|
||||
return null
|
||||
|
||||
|
||||
|
||||
|
||||
func load_from_config():
|
||||
var config = ConfigFile.new()
|
||||
var err = config.load( config_file )
|
||||
if err:# Assuming that file is missing, generate default config
|
||||
config.save( config_file )
|
||||
else:
|
||||
|
||||
|
||||
# on initialise l'entrée, si elle n'existe pas déjà, par la valeur par defaut du projet.
|
||||
if not config.has_section_key("keyboard", action_name):
|
||||
for event in InputMap.get_action_list( action_name ):
|
||||
if event is InputEventKey:
|
||||
var scancode = OS.get_scancode_string( event.get_scancode_with_modifiers() )
|
||||
config.set_value("keyboard", action_name, scancode)
|
||||
break
|
||||
break
|
||||
# on initialise l'entrée alternative, si elle n'existe pas déjà, par la valeur par defaut du projet.
|
||||
var is_first = true
|
||||
if not config.has_section_key("keyboard_alt", action_name):
|
||||
|
@ -126,19 +126,19 @@ func load_from_config():
|
|||
break
|
||||
if is_first and event is InputEventKey:
|
||||
is_first = false
|
||||
|
||||
|
||||
if not config.has_section_key("joypad", action_name):
|
||||
for event in InputMap.get_action_list( action_name ):
|
||||
if event is InputEventJoypadButton:
|
||||
var scancode = Input.get_joy_button_string( event.button_index )
|
||||
config.set_value("joypad", action_name, scancode)
|
||||
break
|
||||
|
||||
break
|
||||
|
||||
# On efface toutes les touches de clavier de l'InputMap correspondants à l'action en cours.
|
||||
for old_event in InputMap.get_action_list( action_name ):
|
||||
if old_event is InputEventKey or old_event is InputEventJoypadButton:
|
||||
InputMap.action_erase_event(action_name, old_event)
|
||||
|
||||
|
||||
# on recupere les touches du fichier de config et on les ajoutes à l'input map.
|
||||
if config.has_section("keyboard"):
|
||||
var action_found = false
|
||||
|
@ -148,7 +148,7 @@ func load_from_config():
|
|||
var event = get_event_with_modifier_from_string( config.get_value("keyboard", action_name), "keyboard")
|
||||
InputMap.action_add_event(action_name, event)
|
||||
break
|
||||
|
||||
|
||||
if config.has_section("keyboard_alt"):
|
||||
var action_found = false
|
||||
for action in config.get_section_keys("keyboard_alt"):
|
||||
|
@ -157,7 +157,7 @@ func load_from_config():
|
|||
var event = get_event_with_modifier_from_string( config.get_value("keyboard_alt", action_name), "keyboard")
|
||||
InputMap.action_add_event(action_name, event)
|
||||
break
|
||||
|
||||
|
||||
if config.has_section("joypad"):
|
||||
var action_found = false
|
||||
for action in config.get_section_keys("joypad"):
|
||||
|
@ -168,35 +168,35 @@ func load_from_config():
|
|||
if old_event is InputEventJoypadButton:
|
||||
InputMap.action_erase_event(action_name, old_event)
|
||||
InputMap.action_add_event(action_name, event)
|
||||
|
||||
config.save( config_file )
|
||||
|
||||
|
||||
|
||||
config.save( config_file )
|
||||
|
||||
|
||||
|
||||
func save_to_config(section, key, value):
|
||||
var config = ConfigFile.new()
|
||||
var err = config.load( config_file )
|
||||
if err:
|
||||
print("Error code when loading config file: ", err)
|
||||
print("[input_map_button_node:save_to_config] Error code when loading config file: ", err)
|
||||
else:
|
||||
config.set_value(section, key, value)
|
||||
config.save( config_file )
|
||||
|
||||
|
||||
|
||||
# Input management
|
||||
func wait_for_input():
|
||||
current_keyboard = $keyboard
|
||||
set_process_input(true)
|
||||
|
||||
|
||||
func wait_for_input_alt():
|
||||
current_keyboard = $keyboard_alt
|
||||
set_process_input(true)
|
||||
# Input management
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey and not event.pressed and not event.is_echo():
|
||||
var input_string = OS.get_scancode_string( event.scancode )
|
||||
|
||||
|
||||
if not event.is_action("ui_cancel") \
|
||||
and not input_string == "Meta" \
|
||||
and not input_string == "Control" \
|
||||
|
@ -216,8 +216,8 @@ func _input(event):
|
|||
if event.shift:
|
||||
current_keyboard.text += "Shift+"
|
||||
current_keyboard.text += input_string
|
||||
|
||||
|
||||
|
||||
|
||||
var change_first_key = true
|
||||
if current_keyboard.name == "keyboard_alt":
|
||||
change_first_key = false
|
||||
|
@ -233,17 +233,17 @@ func _input(event):
|
|||
|
||||
InputMap.action_add_event(action_name, event)
|
||||
save_to_config(current_keyboard.name, action_name, current_keyboard.text)
|
||||
|
||||
|
||||
elif event is InputEventJoypadButton and not event.pressed and not event.is_echo():
|
||||
var input_string = Input.get_joy_button_string( event.button_index )
|
||||
|
||||
get_tree().set_input_as_handled()
|
||||
set_process_input( false )
|
||||
|
||||
|
||||
$joypad.text = input_string
|
||||
for old_event in InputMap.get_action_list( action_name ):
|
||||
if old_event is InputEventJoypadButton:
|
||||
InputMap.action_erase_event(action_name, old_event)
|
||||
InputMap.action_add_event(action_name, event)
|
||||
save_to_config("joypad", action_name, $joypad.text)
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ 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)
|
||||
print("[res://gui_scene/GUI/HUD/HUD.gd:_ready] Error code when loading config file: ", err)
|
||||
else:
|
||||
for child in get_node("Windows" ).get_children():
|
||||
child.load_from_file( config_file )
|
||||
|
@ -21,7 +21,7 @@ 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)
|
||||
print("[res://gui_scene/GUI/HUD/HUD.gd:_on_SaveHUD_pressed] Error code when loading config file: ", err)
|
||||
|
||||
|
||||
for child in get_node("Windows" ).get_children():
|
||||
|
|
|
@ -28,7 +28,7 @@ func load_settings():
|
|||
config_file.set_value( "theme", "font_size", 14 )
|
||||
config_file.save( "user://settings.cfg" )
|
||||
elif not err == OK:
|
||||
print("Error code when loading config file: ", err)
|
||||
print("[res://gui_scene/GUI/Settings/Settings.gd:load_settings] Error code when loading config file: ", err)
|
||||
|
||||
global.font_size = config_file.get_value( "theme", "font_size" )
|
||||
if $Menus.get_theme():
|
||||
|
@ -37,7 +37,7 @@ func load_settings():
|
|||
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size/font_size_value.text = str( global.font_size )
|
||||
|
||||
#var connexion = load("res://assets/Scripts/Config/connexion.gd").new()
|
||||
var script_connexion = load("res://assets/Scripts/Config/connexion.gd")
|
||||
var script_connexion = preload("res://assets/Scripts/Config/connexion.gd")
|
||||
var connexion = script_connexion.connexion.new()
|
||||
var language = connexion.get_language()
|
||||
$Menus/TabContainer/connexion/v_box_container/h_box_container/register.text = connexion.get_url_register()
|
||||
|
@ -56,7 +56,7 @@ func load_settings():
|
|||
# var config_file = ConfigFile.new()
|
||||
# var err = config_file.load( "user://settings.cfg" )
|
||||
# if err:
|
||||
# print("Error code when loading config file: ", err)
|
||||
# print("[Settings:_on_ReturnButton_pressed] Error code when loading config file: ", err)
|
||||
# config_file.set_value("theme", "font_size", $Menus.get_theme().default_font.size)
|
||||
# config_file.save( "user://settings.cfg" )
|
||||
# emit_signal( "return_pressed" )
|
||||
|
@ -101,12 +101,12 @@ func _on_ApplyButton_pressed():
|
|||
var config_file = ConfigFile.new()
|
||||
var err = config_file.load( "user://settings.cfg" )
|
||||
if err:
|
||||
print("Error code when loading config file: ", err)
|
||||
print("[res://gui_scene/GUI/Settings/Settings.gd:_on_ApplyButton_pressed] Error code when loading config file: ", err)
|
||||
config_file.set_value("theme", "font_size", $Menus.get_theme().default_font.size)
|
||||
config_file.save( "user://settings.cfg" )
|
||||
|
||||
# Save Connexion
|
||||
var script_connexion = load("res://assets/Scripts/Config/connexion.gd")
|
||||
var script_connexion = preload("res://assets/Scripts/Config/connexion.gd")
|
||||
var connexion = script_connexion.connexion.new()
|
||||
connexion.set_url_register($Menus/TabContainer/connexion/v_box_container/h_box_container/register.text)
|
||||
connexion.set_url_login($Menus/TabContainer/connexion/v_box_container/h_box_container2/connexion.text)
|
||||
|
|
|
@ -7,7 +7,7 @@ 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)
|
||||
print("[res://scenes/GUI/HUD/HUD.gd:_ready] Error code when loading config file: ", err)
|
||||
else:
|
||||
for child in get_node("Windows" ).get_children():
|
||||
child.load_from_file( config_file )
|
||||
|
@ -15,13 +15,13 @@ func _ready():
|
|||
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)
|
||||
print("[res://scenes/GUI/HUD/HUD.gd:_on_SaveHUD_pressed] Error code when loading config file: ", err)
|
||||
|
||||
|
||||
for child in get_node("Windows" ).get_children():
|
||||
|
|
|
@ -26,7 +26,7 @@ func load_settings():
|
|||
config_file.set_value( "theme", "font_size", 14 )
|
||||
config_file.save( "user://settings.cfg" )
|
||||
elif not err == OK:
|
||||
print("Error code when loading config file: ", err)
|
||||
print("[res://scenes/GUI/Settings/Settings.gd:load_settings] Error code when loading config file: ", err)
|
||||
|
||||
global.font_size = config_file.get_value( "theme", "font_size" )
|
||||
if $Menus.get_theme():
|
||||
|
@ -41,7 +41,7 @@ func _on_ReturnButton_pressed():
|
|||
var config_file = ConfigFile.new()
|
||||
var err = config_file.load( "user://settings.cfg" )
|
||||
if err:
|
||||
print("Error code when loading config file: ", err)
|
||||
print("[res://scenes/GUI/Settings/Settings.gd:_on_ReturnButton_pressed] Error code when loading config file: ", err)
|
||||
|
||||
config_file.set_value("theme", "font_size", $Menus.get_theme().default_font.size)
|
||||
|
||||
|
|
Loading…
Reference in a new issue