-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTopBar.gd
41 lines (27 loc) · 1.3 KB
/
TopBar.gd
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
extends PanelContainer
onready var pollution_value_label = $margin/hbox/panel_container/hbox/pollution_value_label
onready var pollution_progress_bar = $margin/hbox/panel_container/pollution_progress_bar
onready var money_label = $margin/hbox/money_label
onready var money_value_label = $margin/hbox/money_value_label
var world
var world_updated = false
func init(_world):
world = _world
world.connect("info_updated", self, "_on_world_info_updated") # warning-ignore: return_value_discarded
update()
func update():
var money_per_cycle = world.get_total_property(Global.StatType.MONEY_PER_CYCLE)
money_value_label.text = Global.human_readable(world.money) + ' (+' + Global.human_readable(money_per_cycle) + ')'
var tooltip = 'Money (+Money-per-Cycle): ' + str(world.money) + ' (+' + str(money_per_cycle) + ')'
money_value_label.hint_tooltip = tooltip
money_label.hint_tooltip = tooltip
var pollution_progress = float(world.pollution) / world.MAX_POLLUTION
var pollution_percent = int(pollution_progress * 100)
pollution_value_label.text = str(world.pollution) + ' (' + str(pollution_percent) + '%)'
pollution_progress_bar.value = pollution_progress
func _process(_delta):
if world_updated:
update()
world_updated = false
func _on_world_info_updated(_world, _item, _value):
world_updated = true