Click on bg resets icon cursor.
This commit is contained in:
1 parent
b4dc4691e6
commit
c08e04f00b
4 files changed
+25
-10
No files matched your search
@@ -4,6 +4,8 @@ var item_count_manager: ESCItemCountManager
|
||||
|
||||
var tooltip_manager: ESCTootltipManager
|
||||
|
||||
var cursor_manager: RTMICursorManager = RTMICursorManager.new()
|
||||
|
||||
func get_item(global_id: String) -> ESCItem:
|
||||
var object = escoria.object_manager.get_object(global_id)
|
||||
if !object:
|
||||
|
||||
@@ -92,6 +92,7 @@ func _init():
|
||||
func _ready():
|
||||
# We need a slightly modified version of Action Manager to combine items with different actions.
|
||||
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:
|
||||
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 ##
|
||||
|
||||
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 escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
|
||||
Input.set_custom_mouse_cursor(null)
|
||||
escoria.action_manager.clear_current_tool()
|
||||
gymkhana.cursor_manager.clear_cursor()
|
||||
|
||||
|
||||
if escoria.main.current_scene.player:
|
||||
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:
|
||||
# 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:
|
||||
Input.set_custom_mouse_cursor(null)
|
||||
gymkhana.cursor_manager.clear_cursor()
|
||||
action = ACTION3 if action == ACTION1 else ACTION4
|
||||
|
||||
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 ##
|
||||
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 escoria.action_manager.action_state == null:
|
||||
gymkhana.cursor_manager.clear_cursor()
|
||||
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)
|
||||
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 action in target_obj.combine_when_selected_action_is_in:
|
||||
var texture = target_obj.inventory_texture
|
||||
var cursor = ImageTexture.new()
|
||||
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)
|
||||
gymkhana.cursor_manager.set_cursor(texture)
|
||||
|
||||
escoria.action_manager.do(
|
||||
escoria.action_manager.ACTION.ITEM_LEFT_CLICK,
|
||||
|
||||
@@ -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()
|
||||
@@ -0,0 +1 @@
|
||||
uid://dfp2bataokgiw
|
||||
Reference in new issue
Block a user