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.