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

47 lines
1.8 KiB
GDScript

class_name ABGM52ActionDock
extends Button
const UIFactory = preload("res://ui/shared/ui_factory.gd")
const MarketChrome = preload("res://ui/shared/market_chrome.gd")
func configure(text_value: String, disabled := false) -> ABGM52ActionDock:
self.disabled = disabled
_set_meta_text(text_value)
return self
func _ready() -> void:
flat = true
focus_mode = Control.FOCUS_ALL
custom_minimum_size = Vector2(0, 48)
for state in ["normal", "hover", "pressed", "disabled", "focus", "hover_pressed"]:
add_theme_stylebox_override(state, StyleBoxEmpty.new())
var chrome := MarketChrome.new().configure("ledger_action")
chrome.name = "ActionChrome"
chrome.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
chrome.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(chrome)
var icon := UIFactory.attach_icon(self, "inspect", "ActionIcon", "light", Rect2(0.05, 0.19, 0.18, 0.62))
icon.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
var label := UIFactory.label(String(get_meta("action_text", "查看详情")), "label", 1.0, MarketChrome.PAPER_LIGHT)
label.name = "ActionLabel"
label.add_theme_font_size_override("font_size", 14)
# The icon owns 0.05-0.23 of the dock; a fixed 30px inset put the label's
# rect back under the glyph. Anchor the label past the icon instead.
label.anchor_left = 0.26
label.anchor_right = 0.95
label.anchor_top = 0.0
label.anchor_bottom = 1.0
label.offset_left = 0.0
label.offset_right = 0.0
label.offset_top = 0.0
label.offset_bottom = 0.0
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
label.clip_text = true
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(label)
func _set_meta_text(text_value: String) -> void:
set_meta("action_text", text_value)