diff --git a/device/globals/background.gd b/device/globals/background.gd index 28ab0f920..e77714998 100644 --- a/device/globals/background.gd +++ b/device/globals/background.gd @@ -4,9 +4,9 @@ export var action = "walk" func input(event): if event is InputEventMouseButton && event.pressed: - if (event.button_index == 1): - get_tree().call_group_flags(SceneTree.GROUP_CALL_DEFAULT, "game", "clicked", self, get_position() + Vector2(event.position.x, event.position.y)) - elif (event.button_index == 2): + if (event.button_index == BUTTON_LEFT): + get_tree().call_group_flags(SceneTree.GROUP_CALL_DEFAULT, "game", "clicked", self, get_position() + event.position, event) + elif (event.button_index == BUTTON_RIGHT): emit_right_click() func get_action(): diff --git a/device/globals/background_area.gd b/device/globals/background_area.gd index 4d3b0852f..d2c45f830 100644 --- a/device/globals/background_area.gd +++ b/device/globals/background_area.gd @@ -6,9 +6,9 @@ var rectangleshape func input(viewport, event, shape_idx): if event.type == InputEvent.MOUSE_BUTTON && event.pressed: - if (event.button_index == 1): - get_tree().call_group_flags(SceneTree.GROUP_CALL_DEFAULT, "game", "clicked", self, get_position() + Vector2(event.x, event.y)) - elif (event.button_index == 2): + if (event.button_index == BUTTON_LEFT): + get_tree().call_group_flags(SceneTree.GROUP_CALL_DEFAULT, "game", "clicked", self, get_position() + event.position, event) + elif (event.button_index == BUTTON_RIGHT): emit_right_click() func get_action(): diff --git a/device/globals/game.gd b/device/globals/game.gd index 095cb9849..7b140ddd2 100644 --- a/device/globals/game.gd +++ b/device/globals/game.gd @@ -65,7 +65,7 @@ func set_current_action(p_act): func set_current_tool(p_tool): current_tool = p_tool -func clicked(obj, pos): +func clicked(obj, pos, input_event = null): # If multiple areas are clicked at once, an item_background "wins" if obj is Area2D: for area in obj.get_overlapping_areas(): @@ -78,8 +78,9 @@ func clicked(obj, pos): player = self if mode == "default": var action = obj.get_action() - # Hide the action menu when performing actions, so it's not eg. open while walking - action_menu.stop() + # Hide the action menu (where available) when performing actions, so it's not eg. open while walking + if action_menu: + action_menu.stop() if action == "walk": #click.set_position(pos) @@ -108,7 +109,19 @@ func clicked(obj, pos): get_tree().call_group_flags(SceneTree.GROUP_CALL_DEFAULT, "hud", "set_tooltip", "") elif obj.use_action_menu && action_menu != null: - spawn_action_menu(obj) + if ProjectSettings.get_setting("escoria/ui/right_mouse_button_action_menu"): + if input_event.button_index == BUTTON_RIGHT: + spawn_action_menu(obj) + else: + # Left-clicking in this context causes `player` to move to `obj` + if obj.has_node("interact_pos"): + pos = obj.get_node("interact_pos").get_global_position() + else: + pos = obj.get_global_position() + player.walk_to(pos) + # Have to verify left button because `clicked` reacts to any click + elif input_event.button_index == BUTTON_LEFT: + spawn_action_menu(obj) func spawn_action_menu(obj): diff --git a/device/globals/item.gd b/device/globals/item.gd index 5682c483a..def77232b 100644 --- a/device/globals/item.gd +++ b/device/globals/item.gd @@ -98,7 +98,7 @@ func input(event): if event is InputEventMouseButton || event.is_action("ui_accept"): if event.is_pressed(): clicked = true - get_tree().call_group_flags(SceneTree.GROUP_CALL_DEFAULT, "game", "clicked", self, event.get_global_position()) + get_tree().call_group_flags(SceneTree.GROUP_CALL_DEFAULT, "game", "clicked", self, event.get_global_position(), event) _check_focus(true, true) else: clicked = false diff --git a/device/project.godot b/device/project.godot index fec691da7..8a9aac167 100644 --- a/device/project.godot +++ b/device/project.godot @@ -42,12 +42,13 @@ platform/screen_resizable=true platform/show_ingame_buttons=false platform/telon="res://globals/telon.tscn" platform/window_title_height=32 +platform/use_custom_camera=true ui/credits="" ui/in_game_menu="res://ui/in_game_menu.tscn" ui/main_menu="res://ui/main_menu.tscn" ui/confirm_popup="res://ui/confirm_popup.tscn" ui/savegames="" -platform/use_custom_camera=true +ui/right_mouse_button_action_menu=false [gdnative]