Move Escoria settings load action out of init (#414)

InputMap actions added/removed at plugin enabled/disabled
Some changes to README
Co-authored-by: StraToN <StraToN@users.noreply.github.com>
This commit is contained in:
Julian Murgia
2021-10-14 21:56:02 +02:00
committed by GitHub
parent 00de7fcc4d
commit c859cffa33
6 changed files with 36 additions and 11 deletions

View File

@@ -85,7 +85,8 @@ func _ready():
func _input(event) -> void:
if not escoria.current_state == escoria.GAME_STATE.DEFAULT:
return
if event.is_action_pressed("switch_action_verb"):
if InputMap.has_action("switch_action_verb") \
and event.is_action_pressed("switch_action_verb"):
if event.button_index == BUTTON_WHEEL_UP:
emit_signal("mouse_wheel_up")
elif event.button_index == BUTTON_WHEEL_DOWN:

View File

@@ -54,7 +54,8 @@ func _ready():
#
# - event: The event received
func _on_inventory_item_gui_input(event: InputEvent):
if event.is_action_pressed("switch_action_verb"):
if InputMap.has_action("switch_action_verb") \
and event.is_action_pressed("switch_action_verb"):
if event.button_index == BUTTON_WHEEL_UP:
escoria.inputs_manager._on_mousewheel_action(-1)
elif event.button_index == BUTTON_WHEEL_DOWN:

View File

@@ -108,8 +108,6 @@ func _init():
self.controller = ESCController.new()
settings = ESCSaveSettings.new()
settings = save_manager.load_settings()
_on_settings_loaded(settings)
if ProjectSettings.get_setting("escoria/ui/game_scene") == "":
logger.report_errors("escoria.gd",
@@ -123,7 +121,14 @@ func _init():
# Load settings
func _ready():
settings = save_manager.load_settings()
_on_settings_loaded(settings)
inputs_manager.register_core()
if ProjectSettings.get_setting("escoria/main/game_start_script").empty():
logger.report_errors("escoria.gd",
[
"Project setting 'escoria/main/game_start_script' is not set!"
])
start_script = self.esc_compiler.load_esc_file(
ProjectSettings.get_setting("escoria/main/game_start_script")
)
@@ -288,7 +293,8 @@ func _on_settings_loaded(p_settings: ESCSaveSettings) -> void:
# Input function to manage specific input keys
func _input(event):
if event.is_action_pressed("esc_show_debug_prompt"):
if InputMap.has_action("esc_show_debug_prompt") \
and event.is_action_pressed("esc_show_debug_prompt"):
escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
if event.is_action_pressed("ui_cancel"):

View File

@@ -12,6 +12,10 @@ const autoloads = {
func _enter_tree():
for key in autoloads.keys():
add_autoload_singleton(key, autoloads[key])
# Add input actions in InputMap
InputMap.add_action("switch_action_verb")
InputMap.add_action("esc_show_debug_prompt")
# Prepare settings
set_escoria_main_settings()
@@ -291,4 +295,7 @@ func _exit_tree():
if ProjectSettings.has_setting(key):
remove_autoload_singleton(key)
InputMap.erase_action("switch_action_verb")
InputMap.erase_action("esc_show_debug_prompt")