cosmic/scripts/Base/Menu/dialogue.gd
2024-05-22 13:51:54 +03:00

29 lines
886 B
GDScript

extends NinePatchRect
## This message will trigger buy/sell node to fetch buy prices
const BUY_FETCH = "BASE_FETCH_BUY"
## This message will trigger buy/sell node to fetch sell prices
const SELL_FETCH = "BASE_FETCH_SELL"
@onready var dialogue = $DialogueView
@onready var buy_sell = $"../../BuySell"
func _ready():
var tween = create_tween() \
.tween_property(dialogue,"visible_ratio",1.0, 2)
func send_message(msg: Message):
var format = {}
match msg.fact:
BUY_FETCH:
format["sell_list"] = buy_sell.get_buy_sell_list(false)
SELL_FETCH:
format["buy_list"] = buy_sell.get_buy_sell_list(true)
var new_msg = tr(msg.fact + "_RECEIVED").format(format)
print(format)
var old_len = len(dialogue.get_parsed_text())
dialogue.append_text(new_msg)
dialogue.visible_characters = old_len
var tween = create_tween() \
.tween_property(dialogue,"visible_ratio",1.0, 2)