sugary-panda (#1)

Reviewed-on: #1
Co-authored-by: Bryce <bryce@brycecovertoperations.com>
Co-committed-by: Bryce <bryce@brycecovertoperations.com>
This commit was merged in pull request #1.
This commit is contained in:
2026-04-28 22:05:11 -07:00
committed by notid
parent dee6216873
commit 639060fa7f
30 changed files with 2402 additions and 6 deletions

View File

@@ -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
@@ -69,14 +70,46 @@ func set_script_cursor() -> void:
func restore_cursor() -> void:
is_script_running = false
is_cursor_locked = false # Unlock cursor
Input.set_custom_mouse_cursor(cursors[previous_cursor_index])
if previous_cursor_index == ActionState.Action.ITEM:
if item_cursor:
Input.set_custom_mouse_cursor(item_cursor)
else:
Input.set_custom_mouse_cursor(cursors[ActionState.Action.WALK])
else:
Input.set_custom_mouse_cursor(cursors[previous_cursor_index])
func _unhandled_input(event: InputEvent) -> void:
$SceneViewport.push_input(event)
func _on_backpack_show_overlay() -> void:
$InventoryOverlayLayer/InventoryOverlay.show_overlay()
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()
if event.is_action_released("right_click") and not is_cursor_locked:
ActionState.current_action = (ActionState.current_action + 1) % 4
Input.set_custom_mouse_cursor(cursors[ActionState.current_action], Input.CursorShape.CURSOR_ARROW, Vector2(0,0))
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 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))
else:
if prev_action == ActionState.Action.ITEM:
InventoryManager.clear_selection()
Input.set_custom_mouse_cursor(cursors[ActionState.current_action], Input.CursorShape.CURSOR_ARROW, Vector2(0,0))