aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/GameSession/Tooltip.gd
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-08-29 00:16:24 +0200
committer hop311 <hop3114@gmail.com>2024-08-29 23:04:30 +0200
commitbdc2ba527bc02e7cdf977f6040f2ca85aa4f9a94 (patch)
tree4627ad955ac60f5c66b94dfc3106bd8442b58302 /game/src/Game/GameSession/Tooltip.gd
parent88acb31bd43f0e163522837bb1d0dd7da2977c4a (diff)
Add tooltips for buttons, labels, icons, pie charts, sliders, and progress barstooltip
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()