aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/GameSession/Tooltip.gd
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-08-30 23:30:12 +0200
committer GitHub <noreply@github.com>2024-08-30 23:30:12 +0200
commit2e0bc5b556b9c6df46a8cdd48d3f109e0ac76b63 (patch)
tree2c521b99fe6cd0a7fd5d6a29e55645b3415792b3 /game/src/Game/GameSession/Tooltip.gd
parentf54e454afb90f8868e7c62529e2a388fdaadf20b (diff)
parentbdc2ba527bc02e7cdf977f6040f2ca85aa4f9a94 (diff)
Merge pull request #253 from OpenVicProject/tooltip
Tooltips
Diffstat (limited to 'game/src/Game/GameSession/Tooltip.gd')
-rw-r--r--game/src/Game/GameSession/Tooltip.gd23
1 files changed, 23 insertions, 0 deletions
diff --git a/game/src/Game/GameSession/Tooltip.gd b/game/src/Game/GameSession/Tooltip.gd
new file mode 100644
index 0000000..c110e2e
--- /dev/null
+++ b/game/src/Game/GameSession/Tooltip.gd
@@ -0,0 +1,23 @@
+extends GUINode
+
+var _tooltip_label : GUILabel
+
+func _ready() -> void:
+ add_gui_element("core", "ToolTip")
+
+ _tooltip_label = get_gui_label_from_nodepath(^"./ToolTip")
+ if _tooltip_label:
+ _tooltip_label.set_auto_adjust_to_content_size(true)
+
+ MenuSingleton.update_tooltip.connect(update_tooltip)
+
+ hide()
+
+func update_tooltip(text : String, substitution_dict : Dictionary, position : Vector2) -> void:
+ if text:
+ _tooltip_label.set_text(text)
+ _tooltip_label.set_substitution_dict(substitution_dict)
+ _tooltip_label.set_position(position)
+ show()
+ else:
+ hide()