blob: 6353889815183889c0d0f642750cec7a2ad23cf3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
@tool
extends HBoxContainer
# Public properties
var section_colors : Dictionary = {}
var sections : Dictionary = {}:
set(value):
sections = value
_update_sections()
func _update_sections() -> void:
if (!is_inside_tree()):
return
var total = 0.0
for section in sections:
if (section != "Editor"):
total += sections[section]
for section in sections:
if (section == "Editor"):
continue
if (get_node_or_null(section)):
get_node(section).size_flags_stretch_ratio = sections[section] / total
else:
var new_section = preload("res://addons/project-time-tracker/TrackerSectionColor.tscn").instantiate()
new_section.name = section
if section_colors.has(section):
new_section.color = section_colors[section]
else:
new_section.color = section_colors["default"]
new_section.size_flags_stretch_ratio = floor(sections[section]) / floor(sections["Editor"])
add_child(new_section)
func clear():
for child_node in get_children():
remove_child(child_node)
child_node.queue_free()
|