fix: Fixed more input events (#442)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-11-15 10:34:56 +01:00
committed by GitHub
parent c13fde6428
commit b626973f11
4 changed files with 30 additions and 20 deletions

View File

@@ -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():

View File

@@ -84,7 +84,7 @@ func register_background(background: ESCBackground):
"mouse_wheel_up",
self,
"_on_mousewheel_action",
[-1]
[1]
)
background.connect(
"mouse_wheel_down",

View File

@@ -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:

View File

@@ -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"]