Click on bg resets icon cursor.

This commit is contained in:
2025-03-30 04:13:30 +02:00
parent b4dc4691e6
commit c08e04f00b
4 changed files with 25 additions and 10 deletions

View File

@@ -4,6 +4,8 @@ var item_count_manager: ESCItemCountManager
var tooltip_manager: ESCTootltipManager var tooltip_manager: ESCTootltipManager
var cursor_manager: RTMICursorManager = RTMICursorManager.new()
func get_item(global_id: String) -> ESCItem: func get_item(global_id: String) -> ESCItem:
var object = escoria.object_manager.get_object(global_id) var object = escoria.object_manager.get_object(global_id)
if !object: if !object:

View File

@@ -92,6 +92,7 @@ func _init():
func _ready(): func _ready():
# We need a slightly modified version of Action Manager to combine items with different actions. # We need a slightly modified version of Action Manager to combine items with different actions.
escoria.action_manager = ESCActionManagerMonkey.new() escoria.action_manager = ESCActionManagerMonkey.new()
#escoria.di = RTMIDependencyInjector.new()
if $tooltip_layer/tooltip.connect("tooltip_size_updated", Callable(self, "update_tooltip_following_mouse_position").bind(tooltip_node)) != 0: if $tooltip_layer/tooltip.connect("tooltip_size_updated", Callable(self, "update_tooltip_following_mouse_position").bind(tooltip_node)) != 0:
escoria.logger.error(self, "Error connecting tooltip_size_updated with update_tooltip_following_mouse_position") escoria.logger.error(self, "Error connecting tooltip_size_updated with update_tooltip_following_mouse_position")
@@ -235,10 +236,16 @@ func _process_input(event: InputEvent, is_default_state: bool) -> bool:
## BACKGROUND ## ## BACKGROUND ##
func click_on_bg(position: Vector2) -> void: func click_on_bg(position: Vector2) -> void:
var current_state = escoria.action_manager.action_state
if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM:
gymkhana.cursor_manager.clear_cursor()
# If we are using an inventory item reset mouse cursor and cancel action # If we are using an inventory item reset mouse cursor and cancel action
if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM: if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
Input.set_custom_mouse_cursor(null) gymkhana.cursor_manager.clear_cursor()
escoria.action_manager.clear_current_tool()
if escoria.main.current_scene.player: if escoria.main.current_scene.player:
escoria.action_manager.do( escoria.action_manager.do(
@@ -291,7 +298,7 @@ func element_unfocused() -> void:
func click_on_item(item_global_id: String, event: InputEvent, action: String) -> void: func click_on_item(item_global_id: String, event: InputEvent, action: String) -> void:
# If we are using an inventory item reset mouse cursor and use inventory actions (change action1 for action3 and action2 for action4) # If we are using an inventory item reset mouse cursor and use inventory actions (change action1 for action3 and action2 for action4)
if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM: if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
Input.set_custom_mouse_cursor(null) gymkhana.cursor_manager.clear_cursor()
action = ACTION3 if action == ACTION1 else ACTION4 action = ACTION3 if action == ACTION1 else ACTION4
escoria.action_manager.set_current_action(action) escoria.action_manager.set_current_action(action)
@@ -318,8 +325,10 @@ func left_double_click_on_item(item_global_id: String, event: InputEvent) -> voi
## INVENTORY ## ## INVENTORY ##
func click_on_inventory_item(item_global_id: String, event: InputEvent, action: String) -> void: func click_on_inventory_item(item_global_id: String, event: InputEvent, action: String) -> void:
# If we are using an inventory item reset mouse cursor # If we are using an inventory item reset mouse cursor
if escoria.action_manager.action_state == null:
gymkhana.cursor_manager.clear_cursor()
if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM: if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
Input.set_custom_mouse_cursor(null) gymkhana.cursor_manager.clear_cursor()
escoria.action_manager.set_current_action(action) escoria.action_manager.set_current_action(action)
var target_obj = escoria.object_manager.get_object(item_global_id).node var target_obj = escoria.object_manager.get_object(item_global_id).node
@@ -327,12 +336,7 @@ func click_on_inventory_item(item_global_id: String, event: InputEvent, action:
# If item needs combination with this action, use the item texture as mouse cursor # If item needs combination with this action, use the item texture as mouse cursor
if action in target_obj.combine_when_selected_action_is_in: if action in target_obj.combine_when_selected_action_is_in:
var texture = target_obj.inventory_texture var texture = target_obj.inventory_texture
var cursor = ImageTexture.new() gymkhana.cursor_manager.set_cursor(texture)
var texture_image: Image = texture.get_data()
texture_image.resize(texture_image.get_width()/2,texture_image.get_height()/2)
cursor.create_from_image(texture_image)
var middleOfTheTexture = Vector2(texture_image.get_width() / 2, texture_image.get_height() / 2)
Input.set_custom_mouse_cursor(cursor, 0, middleOfTheTexture)
escoria.action_manager.do( escoria.action_manager.do(
escoria.action_manager.ACTION.ITEM_LEFT_CLICK, escoria.action_manager.ACTION.ITEM_LEFT_CLICK,

View File

@@ -0,0 +1,8 @@
class_name RTMICursorManager
func set_cursor(texture: Texture) -> void:
Input.set_custom_mouse_cursor( texture, Input.CURSOR_ARROW, Vector2(32,32))
func clear_cursor():
Input.set_custom_mouse_cursor(null)
escoria.action_manager.clear_current_tool()

View File

@@ -0,0 +1 @@
uid://dfp2bataokgiw