53 lines
1.9 KiB
GDScript
53 lines
1.9 KiB
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"
|
|
## This message will trigger dialogue to get selected item data
|
|
const BUY_ITEM = "BASE_BUY_ITEM"
|
|
## This message will trigger dialogue to get selected item data
|
|
const SELL_ITEM = "BASE_SELL_ITEM"
|
|
## This message will trigger quest node to make answer format
|
|
const TAKE_QUEST = "BASE_TAKE_QUEST"
|
|
|
|
@onready var dialogue = $DialogueView
|
|
@onready var buy_sell = $"../../BuySell"
|
|
@onready var actions_menu = $"../Actions/ActionsMenu"
|
|
@onready var quest = $"../../Quest"
|
|
|
|
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)
|
|
actions_menu.buy = false
|
|
actions_menu.buy_sell_options = buy_sell.get_buy_sell_len(false)
|
|
SELL_FETCH:
|
|
format["buy_list"] = buy_sell.get_buy_sell_list(true)
|
|
actions_menu.buy = true
|
|
actions_menu.buy_sell_options = buy_sell.get_buy_sell_len(true)
|
|
BUY_ITEM:
|
|
var list = buy_sell.items_on_sell
|
|
var id = actions_menu.buy_sell_selected_item
|
|
var item_name = list[id].name
|
|
format["amount"] = actions_menu.buy_sell_amount
|
|
format["item_name"] = item_name
|
|
SELL_ITEM:
|
|
var list = buy_sell.items_on_buy
|
|
var id = actions_menu.buy_sell_selected_item
|
|
var item_name = list[id].name
|
|
format["amount"] = actions_menu.buy_sell_amount
|
|
format["item_name"] = item_name
|
|
TAKE_QUEST:
|
|
format["answer"] = quest.answer
|
|
var new_msg = tr(msg.fact + "_RECEIVED").format(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)
|