Skip to content
Permalink
Browse files

Support a secondary right-click action for items

  • Loading branch information...
fleskesvor authored and Cheeseness committed Apr 20, 2017
1 parent c740ec6 commit f87bfe96cbc98192622cf5f0720f80a7da49696b
Showing with 12 additions and 14 deletions.
  1. +1 −1 globals/background.gd
  2. +3 −1 globals/game.gd
  3. +1 −1 globals/global_vm.gd
  4. +6 −2 globals/item.gd
  5. +1 −9 rooms/test/box.esc
  6. BIN rooms/test/test.scn
@@ -5,7 +5,7 @@ export var action = "walk"
func input(event):
if event.type == InputEvent.MOUSE_BUTTON && event.pressed:
if (event.button_index == 1):
get_tree().call_group(0, "game", "clicked", self, get_pos() + Vector2(event.x, event.y))
get_tree().call_group(0, "game", "clicked", self, get_pos() + Vector2(event.x, event.y), BUTTON_LEFT)
elif (event.button_index == 2):
emit_right_click()

@@ -65,14 +65,16 @@ func set_current_action(p_act):
func set_current_tool(p_tool):
current_tool = p_tool

func clicked(obj, pos):
func clicked(obj, pos, button_index):
joystick_mode = false
if !vm.can_interact():
return
if player == null:
player = self
if mode == "default":
var action = obj.get_action()
if (button_index == BUTTON_RIGHT):
action = obj.get_secondary_action()
#action_menu.stop()
if action == "walk":

@@ -129,7 +129,7 @@ func drag_end():
printt("********** dragging ends")
if hover_object != null && !hover_object.inventory:
printt("calling clicked")
get_tree().call_group(0, "game", "clicked", hover_object, hover_object.get_pos())
get_tree().call_group(0, "game", "clicked", hover_object, hover_object.get_pos(), BUTTON_LEFT)
get_tree().call_group(0, "game", "clear_pending_command")
elif hover_object == null:
get_tree().call_group(0, "game", "clear_pending_command")
@@ -4,6 +4,7 @@ extends "res://globals/interactive.gd"

export var tooltip = ""
export var action = ""
export var secondary_action = ""
export(String,FILE) var events_path = ""
export var global_id = ""
export var use_combine = false
@@ -77,6 +78,9 @@ func activate(p_action, p_param = null):

func get_action():
return action

func get_secondary_action():
return secondary_action

func mouse_enter():
get_tree().call_group(0, "game", "mouse_enter", self)
@@ -89,7 +93,7 @@ func mouse_exit():
func input(event):
if event.type == InputEvent.MOUSE_BUTTON || event.is_action("ui_accept"):
if event.is_pressed():
get_tree().call_group(0, "game", "clicked", self, get_pos())
get_tree().call_group(0, "game", "clicked", self, get_pos(), event.button_index)
_check_focus(true, true)
else:
_check_focus(true, false)
@@ -148,7 +152,7 @@ func drop_data(point, data):
if !inventory:
return

get_tree().call_group(0, "game", "clicked", self, get_pos())
get_tree().call_group(0, "game", "clicked", self, get_pos(), BUTTON_LEFT)
vm.drag_end()


@@ -6,20 +6,12 @@
> [!box_open]
say player "It's a box"

:pick_up
:use

> [box_open]
set_global i/inv_news true
set_active box false

> [!box_open]
say player "It's too heavy!"

:open

> [box_open]
say player "It's already open"

> [!box_open]
set_global box_open true
set_state box newspaper
BIN -378 Bytes (97%) rooms/test/test.scn
Binary file not shown.

0 comments on commit f87bfe9

Please sign in to comment.
You can’t perform that action at this time.