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

@@ -1,4 +1,6 @@
# Escoria Rewrite # Escoria
![Escoria Logo](https://raw.githubusercontent.com/godot-escoria/escoria-demo-game/main/addons/escoria-core/design/escoria-logo-small.png)
Libre framework for the creation of point-and-click adventure games with the MIT-licensed multi-platform game engine [Godot Engine](https://godotengine.org). Libre framework for the creation of point-and-click adventure games with the MIT-licensed multi-platform game engine [Godot Engine](https://godotengine.org).
@@ -36,9 +38,17 @@ In alphabetical order:
* [ESC language documentation](docs/esc.md) * [ESC language documentation](docs/esc.md)
* [API reference](docs/api) * [API reference](docs/api)
## Issues & support
Escoria's development is organized using Github issues.
If you encounter an issue, a bug or a question to developers, please submit a ticket in our [issues page](https://github.com/godot-escoria/escoria-issues/issues).
You can also find support on our official Discord server.
[![Join our Discord](https://img.shields.io/discord/884336424780984330.svg?label=Join%20our%20Discord&logo=Discord&colorB=7289da&style=for-the-badge)](https://discord.com/invite/jMxJjuBY5Z)
## Roadmap ## Roadmap
Escoria's development is organized using Github [issues](https://github.com/godotengine/escoria/issues). Take a look, what's planned for the next version. Take a look, what's planned for the next version in our [projects boards](https://github.com/godot-escoria/escoria-demo-game/projects).
## Licensing ## Licensing

View File

@@ -85,7 +85,8 @@ func _ready():
func _input(event) -> void: func _input(event) -> void:
if not escoria.current_state == escoria.GAME_STATE.DEFAULT: if not escoria.current_state == escoria.GAME_STATE.DEFAULT:
return 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: if event.button_index == BUTTON_WHEEL_UP:
emit_signal("mouse_wheel_up") emit_signal("mouse_wheel_up")
elif event.button_index == BUTTON_WHEEL_DOWN: elif event.button_index == BUTTON_WHEEL_DOWN:

View File

@@ -54,7 +54,8 @@ func _ready():
# #
# - event: The event received # - event: The event received
func _on_inventory_item_gui_input(event: InputEvent): 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: if event.button_index == BUTTON_WHEEL_UP:
escoria.inputs_manager._on_mousewheel_action(-1) escoria.inputs_manager._on_mousewheel_action(-1)
elif event.button_index == BUTTON_WHEEL_DOWN: elif event.button_index == BUTTON_WHEEL_DOWN:

View File

@@ -108,8 +108,6 @@ func _init():
self.controller = ESCController.new() self.controller = ESCController.new()
settings = ESCSaveSettings.new() settings = ESCSaveSettings.new()
settings = save_manager.load_settings()
_on_settings_loaded(settings)
if ProjectSettings.get_setting("escoria/ui/game_scene") == "": if ProjectSettings.get_setting("escoria/ui/game_scene") == "":
logger.report_errors("escoria.gd", logger.report_errors("escoria.gd",
@@ -123,7 +121,14 @@ func _init():
# Load settings # Load settings
func _ready(): func _ready():
settings = save_manager.load_settings()
_on_settings_loaded(settings)
inputs_manager.register_core() 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( start_script = self.esc_compiler.load_esc_file(
ProjectSettings.get_setting("escoria/main/game_start_script") 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 # Input function to manage specific input keys
func _input(event): 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() escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
if event.is_action_pressed("ui_cancel"): if event.is_action_pressed("ui_cancel"):

View File

@@ -13,6 +13,10 @@ func _enter_tree():
for key in autoloads.keys(): for key in autoloads.keys():
add_autoload_singleton(key, autoloads[key]) 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 # Prepare settings
set_escoria_main_settings() set_escoria_main_settings()
set_escoria_debug_settings() set_escoria_debug_settings()
@@ -291,4 +295,7 @@ func _exit_tree():
if ProjectSettings.has_setting(key): if ProjectSettings.has_setting(key):
remove_autoload_singleton(key) remove_autoload_singleton(key)
InputMap.erase_action("switch_action_verb")
InputMap.erase_action("esc_show_debug_prompt")

View File

@@ -13,7 +13,7 @@ Logging framework for Escoria
### LOG\_DEBUG ### LOG\_DEBUG
```gdscript ```gdscript
const LOG_WARNING: int = 1 const LOG_ERROR: int = 0
``` ```
Valid log levels Valid log levels
@@ -21,7 +21,7 @@ Valid log levels
### LOG\_ERROR ### LOG\_ERROR
```gdscript ```gdscript
const LOG_WARNING: int = 1 const LOG_ERROR: int = 0
``` ```
Valid log levels Valid log levels
@@ -29,7 +29,7 @@ Valid log levels
### LOG\_INFO ### LOG\_INFO
```gdscript ```gdscript
const LOG_WARNING: int = 1 const LOG_ERROR: int = 0
``` ```
Valid log levels Valid log levels
@@ -37,7 +37,7 @@ Valid log levels
### LOG\_WARNING ### LOG\_WARNING
```gdscript ```gdscript
const LOG_WARNING: int = 1 const LOG_ERROR: int = 0
``` ```
Valid log levels Valid log levels