2019-06-07 00:02:07 +00:00
|
|
|
extends Panel
|
|
|
|
|
|
|
|
export var barColors: Dictionary = {}
|
|
|
|
export var color: String = "none"
|
2019-06-11 23:13:24 +00:00
|
|
|
export var cardName: String = "Name"
|
|
|
|
export var cardSubname: String = "Subname"
|
|
|
|
export var showCost: bool = false
|
|
|
|
export var cardCost: int = 0
|
|
|
|
|
|
|
|
onready var nameLabel := $TextBlock/NameBlock/Name
|
|
|
|
onready var subnameLabel := $TextBlock/NameBlock/Subname
|
|
|
|
onready var colorIndicator := $ColorIndicator
|
|
|
|
onready var gradientIndicator := $ColorIndicator/TextureRect
|
|
|
|
onready var costIndicator := $TextBlock/CostIndicator
|
|
|
|
onready var costIndicatorLabel := $TextBlock/CostIndicator/CostLabel
|
2019-06-07 00:02:07 +00:00
|
|
|
|
|
|
|
func _ready():
|
2019-06-11 23:13:24 +00:00
|
|
|
nameLabel.text = cardName
|
|
|
|
subnameLabel.text = cardSubname
|
|
|
|
if showCost:
|
|
|
|
costIndicator.visible = true
|
|
|
|
costIndicatorLabel.text = str(cardCost)
|
2019-06-07 00:02:07 +00:00
|
|
|
if color.begins_with("multi|"):
|
|
|
|
make_gradient(color.trim_prefix("multi|").split("+"))
|
|
|
|
else:
|
|
|
|
if not barColors.has(color):
|
|
|
|
color = "none"
|
2019-06-11 23:13:24 +00:00
|
|
|
colorIndicator.color = barColors[color]
|
2019-06-07 00:02:07 +00:00
|
|
|
|
|
|
|
func make_gradient(colors: Array):
|
|
|
|
var gradient := Gradient.new()
|
|
|
|
var step = 1.0/(colors.size() - 1.0)
|
|
|
|
var i = 0
|
|
|
|
gradient.colors = PoolColorArray([])
|
|
|
|
gradient.offsets = PoolRealArray([])
|
|
|
|
for color in colors:
|
|
|
|
var offset: float = i*step
|
|
|
|
gradient.add_point(offset, barColors[color])
|
|
|
|
i += 1
|
|
|
|
var texture := GradientTexture.new()
|
|
|
|
texture.gradient = gradient
|
2019-06-11 23:13:24 +00:00
|
|
|
gradientIndicator.texture = texture
|
|
|
|
gradientIndicator.visible = true
|