Tooltips reworked

This commit is contained in:
2023-02-14 23:58:49 +01:00
parent 61b53578d0
commit 8ec360bb42
8 changed files with 232 additions and 14 deletions

View File

@@ -1,4 +1,45 @@
tool
extends ESCItem
class_name ESCItemWithTooltip, "res://addons/escoria-core/design/esc_item.svg"
# Action 1 Label text
export(String) var action1_text = ""
# Action 2 Label text
export(String) var action2_text = ""
# Action 1 X
export(int) var action1_x = 0
# Action 1 Y
export(int) var action1_y = 0
#$tooltips.visible = true;
var action1Tooltip: Object
var action2Tooltip: Object
var tooltips = []
func _ready():
._ready()
_detect_labels()
if(action1Tooltip != null):
action1Tooltip.set_text(action1_text)
if(action2Tooltip != null):
action2Tooltip.set_text(action2_text)
func _detect_labels() -> void:
# Initialize collision variable.
for c in get_children():
if c is Node2D:
if c.name == "action1":
action1Tooltip = c
if c.name =="action2":
action2Tooltip = c
if c.name == "action1" or c.name =="action2":
print("TOOL LOOP " + c.name)
#var node = c.get
#c.set_text("AAAAAAA")
tooltips.append(c)
#tooltipsLayer = c
# The text for the tooltip of action2
export(String) var tooltip2_name

View File

@@ -0,0 +1,29 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/cursors/mouse_left.png" type="Texture" id=1]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/theme.tres" type="Theme" id=2]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/tooltip-reworked/tooltip-reworked.gd" type="Script" id=3]
[node name="action1" type="Node2D"]
z_index = 500
script = ExtResource( 3 )
[node name="label" type="RichTextLabel" parent="."]
margin_left = 21.0
margin_top = -10.0
margin_right = 235.0
margin_bottom = 41.0
theme = ExtResource( 2 )
bbcode_enabled = true
bbcode_text = "[color=#ffffff] Prueba
[/color]"
text = " Prueba
"
__meta__ = {
"_editor_description_": ""
}
[node name="MouseLeft" type="Sprite" parent="."]
position = Vector2( 13, -2 )
scale = Vector2( 1.3125, 1.25 )
texture = ExtResource( 1 )

View File

@@ -0,0 +1,29 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/cursors/mouse_right.png" type="Texture" id=1]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/theme.tres" type="Theme" id=2]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/tooltip-reworked/tooltip-reworked.gd" type="Script" id=3]
[node name="action2" type="Node2D"]
z_index = 500
script = ExtResource( 3 )
[node name="label" type="RichTextLabel" parent="."]
margin_left = 21.0
margin_top = -10.0
margin_right = 235.0
margin_bottom = 41.0
theme = ExtResource( 2 )
bbcode_enabled = true
bbcode_text = "[color=#ffffff] Prueba
[/color]"
text = " Prueba
"
__meta__ = {
"_editor_description_": ""
}
[node name="MouseRight" type="Sprite" parent="."]
position = Vector2( 11.5, -1 )
scale = Vector2( 1.3125, 1.25 )
texture = ExtResource( 1 )

View File

@@ -0,0 +1,24 @@
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
self.visible = false;
func set_text(text: String) -> void:
$label.text = text
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_ESCItemWithTooltip_mouse_entered():
self.visible = true # Replace with function body.
func _on_ESCItemWithTooltip_mouse_exited():
self.visible = false # Replace with function body.

View File

@@ -0,0 +1,34 @@
extends CollisionPolygon2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_mouse_entered():
$AnimatedSprite3.play()
func _on_mouse_exited():
$AnimatedSprite3.stop()
func _on_Area2D_mouse_entered():
$AnimatedSprite3.play()
func _on_Area2D_mouse_exited():
$AnimatedSprite3.stop()
func _on_TextureRect_mouse_entered():
$AnimatedSprite3.play()

View File

@@ -2,4 +2,6 @@
say player "Parece que veo a Mikel"
:action2
say player "Esta cerrada por dentro."
#say player "Esta cerrada por dentro."
play_snd res://game/sfx/sounds/doorOpen_2.ogg
change_scene "res://gymkhana/rooms/home/home.tscn"

View File

@@ -0,0 +1,5 @@
:action1
say player "Es naranja"
:action2
say player "Pesa demasiado!"

View File

@@ -1,9 +1,10 @@
[gd_scene load_steps=28 format=2]
[gd_scene load_steps=32 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=1]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_background.gd" type="Script" id=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=3]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_terrain.gd" type="Script" id=4]
[ext_resource path="res://gymkhana/rooms/trasera_cocina/HoverStartAnimation.gd" type="Script" id=5]
[ext_resource path="res://gymkhana/rooms/trasera_cocina/assets/background trasera cocina-pix.png" type="Texture" id=6]
[ext_resource path="res://game/characters/mark/mark.tscn" type="PackedScene" id=7]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=8]
@@ -25,6 +26,9 @@
[ext_resource path="res://gymkhana/rooms/trasera_cocina/assets/eneko-anim/unscreen-008.png" type="Texture" id=24]
[ext_resource path="res://gymkhana/rooms/trasera_cocina/assets/columna.png" type="Texture" id=25]
[ext_resource path="res://gymkhana/rooms/trasera_cocina/assets/background trasera cocina-pix-height.png" type="Texture" id=26]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/item.gd" type="Script" id=27]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/tooltip-reworked/tooltip-action2.tscn" type="PackedScene" id=28]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/tooltip-reworked/tooltip-action1.tscn" type="PackedScene" id=29]
[sub_resource type="SpriteFrames" id=2]
animations = [ {
@@ -56,19 +60,11 @@ mouse_filter = 2
texture = ExtResource( 6 )
script = ExtResource( 2 )
[node name="AnimatedSprite3" type="AnimatedSprite" parent="."]
position = Vector2( 643, 359 )
scale = Vector2( 0.752992, 0.752993 )
frames = SubResource( 2 )
frame = 5
playing = true
offset = Vector2( -0.09375, 20.0582 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( 1476, 363 )
scale = Vector2( 0.634168, 0.634168 )
frames = SubResource( 2 )
frame = 8
frame = 11
playing = true
flip_h = true
@@ -76,7 +72,7 @@ flip_h = true
position = Vector2( 1018, 333 )
scale = Vector2( 0.867751, 0.867751 )
frames = SubResource( 2 )
frame = 7
frame = 10
playing = true
offset = Vector2( -0.09375, 20.0582 )
@@ -103,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 )
@@ -122,3 +119,60 @@ position = Vector2( 253.25, 294.5 )
scale = Vector2( 0.973684, 1.02358 )
z_index = 400
texture = ExtResource( 25 )
[node name="TextureRect" type="TextureRect" parent="."]
margin_left = 598.0
margin_top = 283.0
margin_right = 692.0
margin_bottom = 464.0
[node name="Area2D" type="Area2D" parent="."]
position = Vector2( 598, 283 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Area2D"]
polygon = PoolVector2Array( 15, 112, 29, 118, 31, 147, 29, 181, 56, 186, 63, 174, 81, 186, 105, 185, 95, 156, 102, 112, 92, 89, 94, 50, 79, 27, 69, 17, 42, -4, 32, 19, 20, 31, 0, 71, 18, 86 )
script = ExtResource( 5 )
[node name="AnimatedSprite3" type="AnimatedSprite" parent="Area2D/CollisionPolygon2D"]
position = Vector2( 53, 77 )
scale = Vector2( 0.752992, 0.752993 )
frames = SubResource( 2 )
offset = Vector2( -0.09375, 20.0582 )
[node name="TextureRect" type="TextureRect" parent="Area2D"]
margin_right = 40.0
margin_bottom = 40.0
[node name="I_Bombona" type="Area2D" parent="."]
pause_mode = 1
position = Vector2( 557, 408 )
script = ExtResource( 27 )
global_id = "i_bombona"
esc_script = "res://gymkhana/rooms/trasera_cocina/esc/i_bombona.esc"
default_action = "action1"
combine_when_selected_action_is_in = [ ]
dialog_color = Color( 1, 1, 1, 1 )
action1_text = "Mirar bombona"
action2_text = "Coger bombona"
animations = null
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="I_Bombona"]
polygon = PoolVector2Array( -13, -19, -14, -3, -15, 30, -4, 34, 10, 32, 20, 29, 22, 16, 22, -6, 21, -19, 12, -28, 1, -28 )
[node name="action1" parent="I_Bombona" instance=ExtResource( 29 )]
position = Vector2( -53, -48 )
[node name="action2" parent="I_Bombona" instance=ExtResource( 28 )]
position = Vector2( -13, 51 )
[node name="ESCLocation" type="Position2D" parent="I_Bombona"]
position = Vector2( -65, 57 )
script = ExtResource( 3 )
[connection signal="mouse_entered" from="TextureRect" to="Area2D/CollisionPolygon2D" method="_on_TextureRect_mouse_entered"]
[connection signal="mouse_entered" from="Area2D" to="Area2D/CollisionPolygon2D" method="_on_Area2D_mouse_entered"]
[connection signal="mouse_exited" from="Area2D" to="Area2D/CollisionPolygon2D" method="_on_Area2D_mouse_exited"]
[connection signal="mouse_entered" from="I_Bombona" to="I_Bombona/action1" method="_on_ESCItemWithTooltip_mouse_entered"]
[connection signal="mouse_entered" from="I_Bombona" to="I_Bombona/action2" method="_on_ESCItemWithTooltip_mouse_entered"]
[connection signal="mouse_exited" from="I_Bombona" to="I_Bombona/action1" method="_on_ESCItemWithTooltip_mouse_exited"]
[connection signal="mouse_exited" from="I_Bombona" to="I_Bombona/action2" method="_on_ESCItemWithTooltip_mouse_exited"]