@@ -72,9 +72,14 @@ var _is_gamepad_connected = false
|
||||
# Tracks the mouse's current position onscreen.
|
||||
var _current_mouse_pos = Vector2.ZERO
|
||||
|
||||
# A reference to the node handling tooltip2
|
||||
var tooltip2_node: Object
|
||||
|
||||
func _ready():
|
||||
if $tooltip_layer/tooltip.connect("tooltip_size_updated", self, "update_tooltip_following_mouse_position", [tooltip_node]) != 0:
|
||||
escoria.logger.error(self, "Error connecting tooltip_size_updated")
|
||||
if $tooltip_layer/tooltip2.connect("tooltip2_size_updated", self, "update_tooltip_following_mouse_position", [tooltip2_node]) != 0:
|
||||
escoria.logger.error(self, "Error connecting tooltip2_size_updated")
|
||||
|
||||
|
||||
func _enter_tree():
|
||||
@@ -113,6 +118,7 @@ func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
_current_mouse_pos = get_global_mouse_position()
|
||||
update_tooltip_following_mouse_position(tooltip_node)
|
||||
update_tooltip_following_mouse_position(tooltip2_node)
|
||||
|
||||
|
||||
# https://github.com/godotengine/godot-demo-projects/blob/3.4-585455e/misc/joypads/joypads.gd
|
||||
@@ -214,9 +220,11 @@ func left_double_click_on_bg(position: Vector2) -> void:
|
||||
func element_focused(element_id: String) -> void:
|
||||
var target_obj = escoria.object_manager.get_object(element_id).node
|
||||
$tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
|
||||
$tooltip_layer/tooltip2.set_target(target_obj.tooltip2_name)
|
||||
|
||||
func element_unfocused() -> void:
|
||||
$tooltip_layer/tooltip.set_target("")
|
||||
$tooltip_layer/tooltip2.set_target("")
|
||||
|
||||
|
||||
## ITEMS ##
|
||||
@@ -231,8 +239,9 @@ func click_on_item(item_global_id: String, event: InputEvent, action: String) ->
|
||||
true
|
||||
)
|
||||
|
||||
if (action == ACTION1 && target_obj.tooltip_name != ""):
|
||||
if (action == ACTION1 && target_obj.tooltip_name != "") || (action == ACTION2 && target_obj.tooltip2_name != ""):
|
||||
$tooltip_layer/tooltip.hide()
|
||||
$tooltip_layer/tooltip2.hide()
|
||||
|
||||
func left_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
click_on_item(item_global_id, event, ACTION1)
|
||||
@@ -266,6 +275,7 @@ func inventory_item_focused(inventory_item_global_id: String) -> void:
|
||||
|
||||
func inventory_item_unfocused() -> void:
|
||||
$tooltip_layer/tooltip.set_target("")
|
||||
$tooltip_layer/tooltip2.set_target("")
|
||||
|
||||
func open_inventory():
|
||||
$CanvasLayer/ui/HBoxContainer/inventory_ui.show_inventory()
|
||||
@@ -361,6 +371,7 @@ func _on_event_done(return_code: int, _event_name: String):
|
||||
if return_code == ESCExecution.RC_OK:
|
||||
escoria.action_manager.clear_current_action()
|
||||
$tooltip_layer/tooltip.show()
|
||||
$tooltip_layer/tooltip2.show()
|
||||
|
||||
|
||||
func _on_MenuButton_pressed() -> void:
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
[ext_resource path="res://addons/escoria-core/ui_library/menus/main_menu/main_menu.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/theme.tres" type="Theme" id=9]
|
||||
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/tooltip/target_tooltip2.tscn" type="PackedScene" id=10]
|
||||
|
||||
[node name="game" type="Node2D"]
|
||||
script = ExtResource( 5 )
|
||||
@@ -84,4 +85,10 @@ theme = ExtResource( 9 )
|
||||
bbcode_text = "[center][color=#000000][/color][/center]"
|
||||
fit_content_height = true
|
||||
|
||||
[node name="tooltip2" parent="tooltip_layer" instance=ExtResource( 10 )]
|
||||
mouse_filter = 2
|
||||
theme = ExtResource( 9 )
|
||||
bbcode_text = "[center][color=#000000][/color][/center]"
|
||||
fit_content_height = true
|
||||
|
||||
[connection signal="pressed" from="CanvasLayer/ui/HBoxContainer/VBoxContainer/MenuButton" to="." method="_on_MenuButton_pressed"]
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/tooltip/tooltip2_target.gd" type="Script" id=2]
|
||||
|
||||
[node name="tooltip" type="RichTextLabel"]
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "[center][color=#ffffff][/color][/center]"
|
||||
scroll_active = false
|
||||
script = ExtResource( 2 )
|
||||
color = Color( 1, 1, 1, 1 )
|
||||
offset_from_cursor = Vector2( 0, 50 )
|
||||
@@ -0,0 +1,57 @@
|
||||
extends ESCTooltip
|
||||
|
||||
var id: int
|
||||
|
||||
|
||||
export(Texture) var iconTexture: Texture = null \
|
||||
setget ,_get_icon_texture
|
||||
|
||||
func _init(tooltip_id = 0):
|
||||
id = tooltip_id
|
||||
|
||||
#$icon.texture = iconTexture
|
||||
|
||||
|
||||
|
||||
|
||||
signal tooltip2_size_updated
|
||||
|
||||
|
||||
func update_tooltip_text():
|
||||
# Need to update size of bbcode rect before updating the text itself otherwise on the
|
||||
# first frame the text is wider than the default of 0 and ends up being really tall
|
||||
# and setting the wrong vertical margin for the tooltip
|
||||
update_size()
|
||||
#var texturePath = get_constant()
|
||||
var texturePath = null
|
||||
# We signal this here since the processing in this class happens AFTER input
|
||||
# processing. We signal here to avoid "lagging" behind a frame since
|
||||
# tooltips are presently dependent on the size of the bounding box around
|
||||
# the rendered string.
|
||||
emit_signal("tooltip2_size_updated")
|
||||
bbcode_text = "[center]"
|
||||
#if(texturePath != null):
|
||||
bbcode_text += "[img]" + "res://gymkhana/addons/escoria-ui-return-monkey-island/cursors/mouse_right.png" + "[/img]"
|
||||
bbcode_text += "[color=#" + color.to_html(false) + "]"
|
||||
bbcode_text += current_target
|
||||
bbcode_text += "[/color]"
|
||||
bbcode_text += "[/center]"
|
||||
# push_align(RichTextLabel.ALIGN_CENTER)
|
||||
# push_color(color)
|
||||
# append_bbcode(current_target)
|
||||
# pop()
|
||||
# pop()
|
||||
|
||||
|
||||
func _on_room_ready():
|
||||
escoria.main.current_scene.game.tooltip2_node = self
|
||||
_room_is_ready = true
|
||||
|
||||
func _get_icon_texture() -> Texture:
|
||||
if iconTexture == null:
|
||||
for c in get_children():
|
||||
if c is TextureRect or c is Sprite:
|
||||
return c.texture
|
||||
return null
|
||||
else:
|
||||
return iconTexture
|
||||
@@ -109,6 +109,7 @@ tooltip_name = "This is action1"
|
||||
combine_when_selected_action_is_in = [ ]
|
||||
inventory_texture = ExtResource( 10 )
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltip2_name = "This is action2"
|
||||
|
||||
[node name="Art1" type="Sprite" parent="Hotspots/artwork1"]
|
||||
position = Vector2( 470, 140 )
|
||||
|
||||
@@ -99,6 +99,7 @@ global_id = "l_exit"
|
||||
esc_script = "res://gymkhana/rooms/trasera_cocina/esc/entrada_cocina.esc"
|
||||
is_exit = true
|
||||
tooltip_name = "Esto es una puerta"
|
||||
tooltip2_name = "Entrar!"
|
||||
default_action = "action2"
|
||||
combine_when_selected_action_is_in = [ ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
|
||||
@@ -319,11 +319,6 @@ _global_script_classes=[ {
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/escoria-core/game/core-scripts/esc_item.gd"
|
||||
}, {
|
||||
"base": "ESCItem",
|
||||
"class": "ESCItemWithTooltip",
|
||||
"language": "GDScript",
|
||||
"path": "res://gymkhana/addons/escoria-ui-return-monkey-island/item.gd"
|
||||
}, {
|
||||
"base": "Position2D",
|
||||
"class": "ESCLocation",
|
||||
"language": "GDScript",
|
||||
@@ -752,7 +747,6 @@ _global_script_class_icons={
|
||||
"ESCInventoryItem": "",
|
||||
"ESCInventoryManager": "",
|
||||
"ESCItem": "res://addons/escoria-core/design/esc_item.svg",
|
||||
"ESCItemWithTooltip": "res://addons/escoria-core/design/esc_item.svg",
|
||||
"ESCLocation": "res://addons/escoria-core/design/esc_location.svg",
|
||||
"ESCMain": "",
|
||||
"ESCMigration": "",
|
||||
|
||||
Reference in New Issue
Block a user