Files
aetherbound-guild/runtime/ui/m52/trait_module.gd
T

37 lines
1.3 KiB
GDScript

class_name ABGM52TraitModule
extends Control
const MarketChrome = preload("res://ui/shared/market_chrome.gd")
const UIFactory = preload("res://ui/shared/ui_factory.gd")
const TRAIT_BADGE = preload("res://assets/ui_m52_components/v2_trimmed/frames/trait_badge.png")
var value := ""
func configure(next_value: String) -> ABGM52TraitModule:
value = next_value
return self
func _ready() -> void:
clip_contents = true
var badge := TextureRect.new()
badge.name = "TraitBadge"
badge.texture = TRAIT_BADGE
badge.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
badge.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
badge.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
badge.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
badge.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(badge)
var label := UIFactory.label(value, "micro", 1.0, MarketChrome.INK_SOFT)
label.name = "TraitLabel"
label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
label.offset_left = 6.0
label.offset_right = -6.0
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
label.clip_text = true
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(label)