conforms file names to consistant standard
This commit is contained in:
65
ui/cassette_description_ui.gd
Normal file
65
ui/cassette_description_ui.gd
Normal file
@@ -0,0 +1,65 @@
|
||||
class_name cassetteDescriptionUI
|
||||
extends VBoxContainer
|
||||
|
||||
@export var cassette_name_label: Label
|
||||
@export var cassette_description_label: RichTextLabel
|
||||
@export var feature_list: VBoxContainer
|
||||
@export var feature_scene: PackedScene
|
||||
@export var target_list: VBoxContainer
|
||||
|
||||
var cassette: Cassette
|
||||
var side_a: bool
|
||||
|
||||
|
||||
func show_cassette_name() -> void:
|
||||
cassette_name_label.visible = true
|
||||
|
||||
|
||||
func hide_cassette_name() -> void:
|
||||
cassette_name_label.visible = false
|
||||
|
||||
|
||||
func set_cassette(new_cassette: Cassette, side: bool) -> void:
|
||||
cassette = new_cassette
|
||||
side_a = !side
|
||||
cassette_name_label.text = tr(cassette.display_name)
|
||||
cassette_description_label.text = process_cassette_text(cassette.tower_stats.tower_features_applied()) if side_a else process_cassette_text(cassette.weapon_stats.weapon_features_applied())
|
||||
populate_features()
|
||||
populate_targets()
|
||||
|
||||
|
||||
func hide_features() -> void:
|
||||
$FeaturesLabel.visible = false
|
||||
$FeaturesVBox.visible = false
|
||||
|
||||
|
||||
func populate_features() -> void:
|
||||
for child: Node in feature_list.get_children():
|
||||
child.queue_free()
|
||||
var cassette_text: CassetteText = cassette.tower_stats if side_a else cassette.weapon_stats
|
||||
for feature: Feature in cassette_text.features:
|
||||
var ui: FeatureUI = feature_scene.instantiate()
|
||||
ui.set_feature(feature)
|
||||
feature_list.add_child(ui)
|
||||
|
||||
|
||||
func populate_targets() -> void:
|
||||
for child: Node in target_list.get_children():
|
||||
child.queue_free()
|
||||
if !side_a:
|
||||
var label: Label = Label.new()
|
||||
label.text = tr("TARGET_ALL")
|
||||
target_list.add_child(label)
|
||||
else:
|
||||
for target: Data.TargetType in cassette.tower_stats.tower_features_applied().target_type:
|
||||
var label: Label = Label.new()
|
||||
label.text = tr(Data.target_type_names[target])
|
||||
target_list.add_child(label)
|
||||
|
||||
|
||||
func process_cassette_text(cassette_text: CassetteText) -> String:
|
||||
var processed_string: String = tr(cassette_text.text)
|
||||
for key: String in cassette_text.attributes:
|
||||
processed_string = processed_string.replace(key, "[color=red]" + str(snapped(cassette_text.attributes[key], 0.01)) + "[color=white]")
|
||||
processed_string = processed_string.replace("%", "")
|
||||
return processed_string
|
||||
Reference in New Issue
Block a user