fix: wire item_confirmed signal and set item cursor icon
This commit is contained in:
15
MainGame.gd
15
MainGame.gd
@@ -3,6 +3,7 @@ extends Node2D
|
||||
|
||||
var cursors = [load("res://boot_icon.png"), load("res://eye_icon.png"), load("res://hand_icon.png"), load("res://speech_icon.png")]
|
||||
var hourglass_cursor = load("res://hourglass_icon.png")
|
||||
var item_cursor: Texture2D = null
|
||||
var previous_cursor_index: int = 0
|
||||
var is_script_running: bool = false
|
||||
var is_cursor_locked: bool = false # When true, hourglass is shown and cursor can't be changed
|
||||
@@ -80,6 +81,16 @@ func _on_backpack_show_overlay() -> void:
|
||||
func _on_backpack_hide_overlay() -> void:
|
||||
$InventoryOverlayLayer/InventoryOverlay.hide_overlay()
|
||||
|
||||
func _on_overlay_item_confirmed(item_id: String) -> void:
|
||||
InventoryManager.select_item(item_id)
|
||||
var def = InventoryManager.get_item_definition(item_id)
|
||||
if def and def.icon:
|
||||
item_cursor = def.icon
|
||||
Input.set_custom_mouse_cursor(item_cursor)
|
||||
ActionState.current_action = ActionState.Action.ITEM
|
||||
else:
|
||||
Input.set_custom_mouse_cursor(cursors[ActionState.Action.WALK])
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_released("quit"):
|
||||
get_tree().quit()
|
||||
@@ -87,8 +98,8 @@ func _input(event):
|
||||
var prev_action = ActionState.current_action
|
||||
ActionState.current_action = (ActionState.current_action + 1) % 5
|
||||
if ActionState.current_action == ActionState.Action.ITEM:
|
||||
if InventoryManager.selected_item:
|
||||
Input.set_custom_mouse_cursor(cursors[ActionState.current_action], Input.CursorShape.CURSOR_ARROW, Vector2(0,0))
|
||||
if InventoryManager.selected_item and item_cursor:
|
||||
Input.set_custom_mouse_cursor(item_cursor, Input.CursorShape.CURSOR_ARROW, Vector2(0,0))
|
||||
else:
|
||||
ActionState.current_action = (ActionState.current_action + 1) % 5
|
||||
Input.set_custom_mouse_cursor(cursors[ActionState.current_action], Input.CursorShape.CURSOR_ARROW, Vector2(0,0))
|
||||
|
||||
Reference in New Issue
Block a user