Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed more input events #442

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/escoria-core/game/core-scripts/esc_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion addons/escoria-core/game/inputs_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func register_background(background: ESCBackground):
"mouse_wheel_up",
self,
"_on_mousewheel_action",
[-1]
[1]
)
background.connect(
"mouse_wheel_down",
Expand Down
20 changes: 10 additions & 10 deletions addons/escoria-ui-simplemouse/game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ##

Expand All @@ -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
)

Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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():
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
26 changes: 18 additions & 8 deletions addons/escoria-ui-simplemouse/game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]