aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Theme/PieChart/LayeredChart.gd
diff options
context:
space:
mode:
author Nemrav <>2023-07-29 03:07:02 +0200
committer Hop311 <hop3114@gmail.com>2023-08-09 20:02:01 +0200
commit505176d9cabe76cff7cdac6b4d4ef1c77ccb00d9 (patch)
treeeed289104a5fc476e9033d88fc74865d109e66bb /game/src/Game/Theme/PieChart/LayeredChart.gd
parentff0d38b5d53fa95609f2587a2be5205f0c0d3118 (diff)
add piecharts
Diffstat (limited to 'game/src/Game/Theme/PieChart/LayeredChart.gd')
-rw-r--r--game/src/Game/Theme/PieChart/LayeredChart.gd28
1 files changed, 28 insertions, 0 deletions
diff --git a/game/src/Game/Theme/PieChart/LayeredChart.gd b/game/src/Game/Theme/PieChart/LayeredChart.gd
new file mode 100644
index 0000000..7bc69c8
--- /dev/null
+++ b/game/src/Game/Theme/PieChart/LayeredChart.gd
@@ -0,0 +1,28 @@
+extends CenterContainer
+
+var overlapping_charts:Array = []
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ for child in get_children():
+ if child is PieChart:
+ overlapping_charts.push_back(child)
+
+#Process mouse to select the appropriate tooltip for the slice
+func _gui_input(event:InputEvent):
+ if event is InputEventMouse:
+ var pos = event.position
+ var handled:bool = false
+ var x = overlapping_charts.size()
+ #process the charts in reverse order (overlying charts first)
+ #as you can't actually make the inner chart(s) smaller with a centerContainer
+ for i in range(x):
+ var chart = overlapping_charts[x-(i+1)]
+ if not handled:
+ handled = chart.handleTooltip(pos)
+ else:
+ chart.RichTooltip.visible = false
+
+func _on_mouse_exited():
+ for chart in overlapping_charts:
+ chart.RichTooltip.visible = false