xiandie/ui/text_helper.gd

23 lines
549 B
GDScript3
Raw Normal View History

2025-07-04 13:02:27 +00:00
@tool
extends Node
@export var property_name := "text"
@export var translation_key := ""
@export_tool_button("刷新") var refresh = _refresh.bind(true)
func _ready() -> void:
_refresh()
# res://asset/dialogue/item_description.zh_CN.translation
var items_translation = preload("uid://c1x5bqwulamey") as Translation
func _refresh(from_tool := false):
if property_name and translation_key:
var msg = tr(translation_key)
if from_tool:
msg = items_translation.get_message(translation_key)
set(property_name, msg.replace("<br>", "\n"))