From 653fb7c0df33cda39b430c2e135cb4922bdb6736 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Mon, 15 Nov 2021 09:40:58 +0100 Subject: [PATCH] fix: Fixed more input events --- .../game/core-scripts/esc_item.gd | 2 +- addons/escoria-core/game/inputs_manager.gd | 2 +- addons/escoria-ui-simplemouse/game.gd | 20 +++++++------- addons/escoria-ui-simplemouse/game.tscn | 26 +++++++++++++------ 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/addons/escoria-core/game/core-scripts/esc_item.gd b/addons/escoria-core/game/core-scripts/esc_item.gd index 2c6e9e72a..302297d7d 100644 --- a/addons/escoria-core/game/core-scripts/esc_item.gd +++ b/addons/escoria-core/game/core-scripts/esc_item.gd @@ -269,7 +269,7 @@ func _ready(): # #### Parameters # # - event: Triggered event -func _input(event: InputEvent) -> void: +func _unhandled_input(event: InputEvent) -> void: if not escoria.current_state == escoria.GAME_STATE.DEFAULT: return if event is InputEventMouseButton and event.is_pressed(): diff --git a/addons/escoria-core/game/inputs_manager.gd b/addons/escoria-core/game/inputs_manager.gd index ff1d9d30b..1e4a7ef32 100644 --- a/addons/escoria-core/game/inputs_manager.gd +++ b/addons/escoria-core/game/inputs_manager.gd @@ -84,7 +84,7 @@ func register_background(background: ESCBackground): "mouse_wheel_up", self, "_on_mousewheel_action", - [-1] + [1] ) background.connect( "mouse_wheel_down", diff --git a/addons/escoria-ui-simplemouse/game.gd b/addons/escoria-ui-simplemouse/game.gd index 3297b1116..0832363ca 100644 --- a/addons/escoria-ui-simplemouse/game.gd +++ b/addons/escoria-ui-simplemouse/game.gd @@ -70,8 +70,8 @@ func left_click_on_bg(position: Vector2) -> void: [escoria.main.current_scene.player.global_id, position], true ) - $CanvasLayer/ui/HBoxContainer/verbs_menu.set_by_name("walk") - $CanvasLayer/ui/HBoxContainer/verbs_menu.clear_tool_texture() + $mouse_layer/verbs_menu.set_by_name("walk") + $mouse_layer/verbs_menu.clear_tool_texture() func right_click_on_bg(position: Vector2) -> void: mousewheel_action(1) @@ -83,8 +83,8 @@ func left_double_click_on_bg(position: Vector2) -> void: [escoria.main.current_scene.player.global_id, position, true], true ) - $CanvasLayer/ui/HBoxContainer/verbs_menu.set_by_name("walk") - $CanvasLayer/ui/HBoxContainer/verbs_menu.clear_tool_texture() + $mouse_layer/verbs_menu.set_by_name("walk") + $mouse_layer/verbs_menu.clear_tool_texture() ## ITEM/HOTSPOT FOCUS ## @@ -95,7 +95,7 @@ func element_focused(element_id: String) -> void: if escoria.action_manager.current_action != "use" \ and escoria.action_manager.current_tool == null: if target_obj is ESCItem: - $CanvasLayer/ui/HBoxContainer/verbs_menu.set_by_name( + $mouse_layer/verbs_menu.set_by_name( target_obj.default_action ) @@ -123,11 +123,11 @@ func left_click_on_inventory_item(inventory_item_global_id: String, event: Input inventory_item_global_id ).node if item.has_method("get_sprite") and item.get_sprite().texture: - $CanvasLayer/ui/HBoxContainer/verbs_menu.set_tool_texture( + $mouse_layer/verbs_menu.set_tool_texture( item.get_sprite().texture ) elif item.inventory_item.texture_normal: - $CanvasLayer/ui/HBoxContainer/verbs_menu.set_tool_texture( + $mouse_layer/verbs_menu.set_tool_texture( item.inventory_item.texture_normal ) @@ -161,7 +161,7 @@ func close_inventory(): func mousewheel_action(direction: int): - $CanvasLayer/ui/HBoxContainer/verbs_menu.iterate_actions_cursor(direction) + $mouse_layer/verbs_menu.iterate_actions_cursor(direction) func hide_ui(): @@ -174,7 +174,7 @@ func show_ui(): func _on_event_done(event_name: String): escoria.action_manager.clear_current_action() - $CanvasLayer/ui/HBoxContainer/verbs_menu.clear_tool_texture() + $mouse_layer/verbs_menu.clear_tool_texture() func hide_main_menu(): if get_node(main_menu).visible: @@ -203,7 +203,7 @@ func pause_game(): func _on_action_finished(): - $CanvasLayer/ui/HBoxContainer/verbs_menu.clear_tool_texture() + $mouse_layer/verbs_menu.clear_tool_texture() func _on_MenuButton_pressed() -> void: diff --git a/addons/escoria-ui-simplemouse/game.tscn b/addons/escoria-ui-simplemouse/game.tscn index 91ef52e68..cee7c7f06 100644 --- a/addons/escoria-ui-simplemouse/game.tscn +++ b/addons/escoria-ui-simplemouse/game.tscn @@ -49,16 +49,11 @@ margin_right = 58.0 margin_bottom = 27.0 text = "Menu" -[node name="verbs_menu" parent="CanvasLayer/ui/HBoxContainer" instance=ExtResource( 4 )] -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="Spacer" type="Control" parent="CanvasLayer/ui/HBoxContainer"] margin_left = 62.0 -margin_right = 62.0 +margin_right = 1186.0 margin_bottom = 90.0 -grow_horizontal = 0 -size_flags_horizontal = 2 -size_flags_vertical = 3 -size_flags_stretch_ratio = 3.0 +size_flags_horizontal = 3 [node name="inventory_ui" parent="CanvasLayer/ui/HBoxContainer" instance=ExtResource( 1 )] anchor_right = 0.0 @@ -95,4 +90,19 @@ bbcode_text = "[center][color=#000000][/color][/center]" fit_content_height = true offset_from_cursor = Vector2( 75, 10 ) +[node name="mouse_layer" type="CanvasLayer" parent="."] +layer = 2 + +[node name="verbs_menu" parent="mouse_layer" instance=ExtResource( 4 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 156.0 +margin_top = 810.0 +margin_right = 156.0 +margin_bottom = 900.0 +grow_horizontal = 0 +size_flags_horizontal = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 3.0 + [connection signal="pressed" from="CanvasLayer/ui/HBoxContainer/VBoxContainer/MenuButton" to="." method="_on_MenuButton_pressed"]