Set a default implementation for ESCGame._on_event_done() (#486)

This commit is contained in:
Julian Murgia
2022-02-04 16:27:21 +01:00
committed by GitHub
parent caac5ef407
commit 353b349d1b
5 changed files with 93 additions and 39 deletions

View File

@@ -36,12 +36,41 @@ export(EDITOR_GAME_DEBUG_DISPLAY) var editor_debug_mode = \
var tooltip_node: Object
# Function called when ESCGame enters the scene tree.
func _enter_tree():
escoria.event_manager.connect(
"event_finished",
self,
"_on_event_done"
)
escoria.action_manager.connect(
"action_finished",
self,
"_on_action_finished"
)
# Function called when ESCGame exits the scene tree.
func _exit_tree():
escoria.action_manager.disconnect(
"event_finished",
self,
"_on_event_done"
)
escoria.action_manager.disconnect(
"action_finished",
self,
"_on_action_finished"
)
# Ready function
func _ready():
escoria.apply_settings(escoria.settings)
connect("crash_popup_confirmed", escoria, "quit",
[], CONNECT_ONESHOT)
# Handle debugging visualizations
func _draw():
if !Engine.is_editor_hint():
@@ -257,11 +286,36 @@ func show_ui():
# Set the Editor debug mode
#
# #### Parameter
#
# - p_editor_debug_mode: EDITOR_GAME_DEBUG_DISPLAY enum (int) value
# corresponding to the desired editor debug mode
func _set_editor_debug_mode(p_editor_debug_mode: int) -> void:
editor_debug_mode = p_editor_debug_mode
update()
# Automatically called whenever an event is finished. Can be used to reset some
# UI elements to their default/empty state. This function can be called before
# _on_action_finished() if the player input started an event.
# Reimplement to performed desired actions.
#
# #### Parameter
#
# - _return_code: return code of the event (type ESCExecution)
# - _event_name: name of the event that was just done (can be unused)
func _on_event_done(_return_code: int, _event_name: String) -> void:
pass
# Automatically called whenever an action initiated by the player is finished.
# Can be used to reset some UI elements to their default/empty state.
# Reimplement to performed desired actions.
func _on_action_finished() -> void:
pass
# Pauses the game. Reimplement to eventually show a specific UI.
func pause_game():
escoria.set_game_paused(true)

View File

@@ -47,12 +47,6 @@ onready var inventory_ui = $ui/Control/panel_down/VBoxContainer/HBoxContainer\
/InventoryMargin/inventory_ui
func _enter_tree():
escoria.action_manager.connect(
"action_finished",
self,
"_on_action_finished"
)
var room_selector_parent = $ui/Control/panel_down/VBoxContainer\
/HBoxContainer/MainMargin/VBoxContainer
@@ -65,14 +59,6 @@ func _enter_tree():
).instance()
)
func _exit_tree():
escoria.action_manager.disconnect(
"action_finished",
self,
"_on_action_finished"
)
## BACKGROUND ##
@@ -301,10 +287,6 @@ func show_ui():
inventory_ui.show()
tooltip.show()
func _on_event_done(_event_name: String):
escoria.action_manager.clear_current_action()
verbs_menu.unselect_actions()
func hide_main_menu():
if get_node(main_menu).visible:
get_node(main_menu).hide()
@@ -343,6 +325,10 @@ func _on_action_finished() -> void:
verbs_menu.unselect_actions()
tooltip.clear()
func _on_event_done(_return_code: int, _event_name: String):
escoria.action_manager.clear_current_action()
verbs_menu.unselect_actions()
func apply_custom_settings(custom_settings: Dictionary):
if custom_settings.has("a_custom_setting"):

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=2]
[gd_scene load_steps=11 format=2]
[ext_resource path="res://addons/escoria-ui-9verbs/tooltip/action_target_tooltip.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/escoria-ui-9verbs/inventory/inventory_ui.tscn" type="PackedScene" id=2]
@@ -7,7 +7,6 @@
[ext_resource path="res://addons/escoria-ui-9verbs/game.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=6]
[ext_resource path="res://addons/escoria-core/ui_library/menus/main_menu/main_menu.tscn" type="PackedScene" id=7]
[ext_resource path="res://addons/escoria-ui-9verbs/tooltip/tooltip_action_target.gd" type="Script" id=8]
[ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.tscn" type="PackedScene" id=9]
[ext_resource path="res://addons/escoria-ui-9verbs/theme.tres" type="Theme" id=10]
@@ -67,7 +66,6 @@ margin_bottom = 32.0
bbcode_text = "[center]Test[/center]"
text = "Test"
fit_content_height = true
script = ExtResource( 8 )
color = Color( 1, 1, 1, 1 )
[node name="HSeparator" type="HSeparator" parent="ui/Control/panel_down/VBoxContainer"]

View File

@@ -38,12 +38,6 @@ Implement methods to react to inputs.
"""
func _enter_tree():
escoria.action_manager.connect(
"action_finished",
self,
"_on_action_finished"
)
var room_selector_parent = $CanvasLayer/ui/HBoxContainer/VBoxContainer
if ProjectSettings.get_setting("escoria/debug/enable_room_selector") and \
@@ -55,13 +49,6 @@ func _enter_tree():
).instance()
)
func _exit_tree():
escoria.action_manager.disconnect(
"action_finished",
self,
"_on_action_finished"
)
func _input(event: InputEvent) -> void:
if escoria.main.current_scene and escoria.main.current_scene.game:
@@ -180,11 +167,6 @@ func hide_ui():
func show_ui():
$CanvasLayer/ui/HBoxContainer/inventory_ui.show()
func _on_event_done(event_name: String):
escoria.action_manager.clear_current_action()
$mouse_layer/verbs_menu.clear_tool_texture()
func hide_main_menu():
if get_node(main_menu).visible:
get_node(main_menu).hide()
@@ -259,6 +241,10 @@ func _on_action_finished():
$mouse_layer/verbs_menu.clear_tool_texture()
$mouse_layer/verbs_menu.iterate_actions_cursor(0)
func _on_event_done(_return_code: int, _event_name: String):
escoria.action_manager.clear_current_action()
$mouse_layer/verbs_menu.clear_tool_texture()
func _on_MenuButton_pressed() -> void:
pause_game()

View File

@@ -0,0 +1,30 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_background.gd" type="Script" id=1]
[node name="background" type="TextureRect"]
margin_right = 1289.0
margin_bottom = 555.0
mouse_filter = 2
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="l_platform" type="Line2D" parent="."]
position = Vector2( 2, -266 )
points = PoolVector2Array( -2.96298, 712.01, 129.973, 614.429, 1167.5, 612.894, 1274.59, 669.705, 1273.25, 812.694, 2.36697, 811.043, 2.36697, 713.389 )
[node name="l_door" type="Line2D" parent="."]
position = Vector2( 0, -266 )
points = PoolVector2Array( 6.61201, 704.409, 6.61203, 389.558, 87.755, 339.775, 87.5463, 649.784 )
__meta__ = {
"_editor_description_": ""
}
[node name="r_door" type="Line2D" parent="."]
position = Vector2( 0, -267.828 )
points = PoolVector2Array( 1175.07, 620.086, 1171.24, 311.267, 1274.8, 356.87, 1278.31, 672.412, 1188.64, 624.843 )
__meta__ = {
"_editor_description_": ""
}