1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2025-04-01 21:30:31 +00:00

Add configurable icon to PurchasableItem

This commit is contained in:
Steffo 2023-10-01 14:50:47 +02:00
parent 94fef9e231
commit 3f59b56aa8
Signed by: steffo
GPG key ID: 2A24051445686895
2 changed files with 23 additions and 6 deletions

View file

@ -1,6 +1,14 @@
extends Panel extends Panel
class_name PurchasableItem class_name PurchasableItem
## Icon of the item that can be purchased.
@export var item_icon: Texture2D:
get:
return item_icon
set(value):
item_icon = value
$Contents/Header/IconRect.texture = item_icon
## Name of the item that can be purchased. ## Name of the item that can be purchased.
@export var item_name: String: @export var item_name: String:
get: get:
@ -39,7 +47,17 @@ class_name PurchasableItem
return can_buy return can_buy
set(value): set(value):
can_buy = value can_buy = value
$Contents/Action/BuyButton.disabled = not can_buy $Contents/Action/BuyButton.disabled = not (can_buy && has_unlocked)
## Whether the player has unlocked this item for purchase.
##
## Used to force the player to follow the tech tree.
@export var has_unlocked: bool = true:
get:
return has_unlocked
set(value):
has_unlocked = value
$Contents/Action/BuyButton.disabled = not (can_buy && has_unlocked)
## Whether the player is currently buying this item. ## Whether the player is currently buying this item.
## ##
@ -72,7 +90,6 @@ func _on_buy_button_pressed():
is_buying = true is_buying = true
purchase_begin.emit() purchase_begin.emit()
func complete_purchase(): func complete_purchase():
is_buying = false is_buying = false
purchase_success.emit() purchase_success.emit()

View file

@ -45,7 +45,7 @@ layout_mode = 2
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20 theme_override_font_sizes/font_size = 20
text = "Garasaut" text = "ITEMNAME"
uppercase = true uppercase = true
[node name="NamePaddingRight" type="Control" parent="Contents/Header"] [node name="NamePaddingRight" type="Control" parent="Contents/Header"]
@ -69,7 +69,7 @@ layout_mode = 2
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
theme_override_font_sizes/font_size = 12 theme_override_font_sizes/font_size = 12
text = "Garasa tutte le auto della zona per ottenere upgrade" text = "What does this item do? Nobody knows."
autowrap_mode = 2 autowrap_mode = 2
[node name="DescriptionPaddingRight" type="Control" parent="Contents/Description"] [node name="DescriptionPaddingRight" type="Control" parent="Contents/Description"]
@ -101,7 +101,7 @@ layout_mode = 2
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
theme_override_font_sizes/font_size = 8 theme_override_font_sizes/font_size = 8
text = "3 copper coins" text = "3 fiorygi"
vertical_alignment = 1 vertical_alignment = 1
[node name="CostLabelPaddingRight" type="Control" parent="Contents/Action"] [node name="CostLabelPaddingRight" type="Control" parent="Contents/Action"]