-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem.gd
55 lines (40 loc) · 1.14 KB
/
item.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class_name Item extends Control
signal delete_item
signal modifier_deleted
signal item_selected
signal modifier_added
@onready var label = $VBoxContainer/HBoxContainer/MarginContainer2/Label
@onready var container = $VBoxContainer
@onready var highlight = $Control/ColorRect2
var title : String
var price : float
var modifiers : Array
var group_id : int
func set_values(_title : String, _price : float, _group_id : int):
title = _title
price = _price
group_id = _group_id
func _ready():
label.set_text(title)
size = Vector2(1920, 400)
func add_modifier(_modifier : Modifier):
modifiers.append(_modifier)
price += _modifier.price
container.add_child(_modifier)
_modifier.delete_modifier.connect(modifier_delete_pressed)
modifier_added.emit()
func remove_modifier(_modifier):
modifiers.erase(_modifier)
price -= _modifier.price
_modifier.queue_free()
modifier_deleted.emit()
func modifier_delete_pressed(_modifier):
remove_modifier(_modifier)
func select():
highlight.visible = true
func deselect():
highlight.visible = false
func _on_label_pressed():
item_selected.emit(self)
func _on_button_pressed():
delete_item.emit(self)