Buy/sell dialogue buttons
This commit is contained in:
parent
a6f9b11c43
commit
53e5dd38b2
8 changed files with 52 additions and 15 deletions
|
|
@ -1,15 +1,15 @@
|
||||||
[gd_resource type="Resource" script_class="Menu" load_steps=4 format=3 uid="uid://cbvax7aprnrig"]
|
[gd_resource type="Resource" script_class="Menu" load_steps=4 format=3 uid="uid://cbvax7aprnrig"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/Classes/Menu/combo_menu_resource.gd" id="1_xamua"]
|
[ext_resource type="Script" path="res://scripts/Classes/Menu/combo_menu_resource.gd" id="1_erxhv"]
|
||||||
[ext_resource type="Script" path="res://scripts/Classes/Menu/menu.gd" id="2_f8fna"]
|
[ext_resource type="Script" path="res://scripts/Classes/Menu/menu.gd" id="2_ppqjr"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_5pmle"]
|
[sub_resource type="Resource" id="Resource_5pmle"]
|
||||||
script = ExtResource("1_xamua")
|
script = ExtResource("1_erxhv")
|
||||||
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
||||||
item_menu = &"res://menus/Base Menu/root_menu.tres"
|
item_menu = &"res://menus/Base Menu/root_menu.tres"
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("2_f8fna")
|
script = ExtResource("2_ppqjr")
|
||||||
item_ids = Array[String](["BASE_FETCH_BUY_CANCEL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"])
|
item_ids = Array[String](["BASE_FETCH_BUY_SELL_CANCEL", "BASE_BUY_SELL", "BASE_BUY_SELL", "BASE_BUY_SELL", "BASE_BUY_SELL", "BASE_BUY_SELL", "BASE_BUY_SELL", "BASE_BUY_SELL_NEXT"])
|
||||||
item_actions = Array[int]([3, 0, 0, 0, 0, 0, 0, 0])
|
item_actions = Array[int]([3, 0, 0, 0, 0, 0, 0, 0])
|
||||||
item_data = Array[Resource("res://scripts/Classes/Menu/menu_resource.gd")]([SubResource("Resource_5pmle"), null, null, null, null, null, null, null])
|
item_data = Array[Resource("res://scripts/Classes/Menu/menu_resource.gd")]([SubResource("Resource_5pmle"), null, null, null, null, null, null, null])
|
||||||
|
|
@ -6,12 +6,12 @@
|
||||||
[sub_resource type="Resource" id="Resource_iiy7m"]
|
[sub_resource type="Resource" id="Resource_iiy7m"]
|
||||||
script = ExtResource("1_d2x8v")
|
script = ExtResource("1_d2x8v")
|
||||||
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
||||||
item_menu = &"res://menus/Base Menu/BuySell/menu_buy.tres"
|
item_menu = &"res://menus/Base Menu/BuySell/menu_buy_sell.tres"
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_pbhiw"]
|
[sub_resource type="Resource" id="Resource_pbhiw"]
|
||||||
script = ExtResource("1_d2x8v")
|
script = ExtResource("1_d2x8v")
|
||||||
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
||||||
item_menu = &"res://menus/Base Menu/BuySell/menu_sell.tres"
|
item_menu = &"res://menus/Base Menu/BuySell/menu_buy_sell.tres"
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_h4chp")
|
script = ExtResource("1_h4chp")
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@ func fetch_items():
|
||||||
items_on_buy = base.items_on_buy
|
items_on_buy = base.items_on_buy
|
||||||
sell_prices = base.sell_prices
|
sell_prices = base.sell_prices
|
||||||
buy_prices = base.buy_prices
|
buy_prices = base.buy_prices
|
||||||
print(base)
|
|
||||||
print(items_on_sell, "\n", items_on_buy)
|
|
||||||
|
|
||||||
## Returns buy/sell description of a selected item
|
## Returns buy/sell description of a selected item
|
||||||
func item_description(buy: bool, id: int) -> String:
|
func item_description(buy: bool, id: int) -> String:
|
||||||
|
|
@ -46,3 +44,7 @@ func get_buy_sell_list(buy: bool) -> String:
|
||||||
for item in range(len(list)):
|
for item in range(len(list)):
|
||||||
total += item_description(buy, item) + "\n"
|
total += item_description(buy, item) + "\n"
|
||||||
return total
|
return total
|
||||||
|
|
||||||
|
func get_buy_sell_len(buy: bool) -> int:
|
||||||
|
var list = items_on_buy if buy else items_on_sell
|
||||||
|
return len(list)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ const SELL_FETCH = "BASE_FETCH_SELL"
|
||||||
|
|
||||||
@onready var dialogue = $DialogueView
|
@onready var dialogue = $DialogueView
|
||||||
@onready var buy_sell = $"../../BuySell"
|
@onready var buy_sell = $"../../BuySell"
|
||||||
|
@onready var actions_menu = $"../Actions/ActionsMenu"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var tween = create_tween() \
|
var tween = create_tween() \
|
||||||
|
|
@ -17,11 +18,14 @@ func send_message(msg: Message):
|
||||||
match msg.fact:
|
match msg.fact:
|
||||||
BUY_FETCH:
|
BUY_FETCH:
|
||||||
format["sell_list"] = buy_sell.get_buy_sell_list(false)
|
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:
|
SELL_FETCH:
|
||||||
format["buy_list"] = buy_sell.get_buy_sell_list(true)
|
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)
|
||||||
|
|
||||||
var new_msg = tr(msg.fact + "_RECEIVED").format(format)
|
var new_msg = tr(msg.fact + "_RECEIVED").format(format)
|
||||||
print(format)
|
|
||||||
var old_len = len(dialogue.get_parsed_text())
|
var old_len = len(dialogue.get_parsed_text())
|
||||||
dialogue.append_text(new_msg)
|
dialogue.append_text(new_msg)
|
||||||
dialogue.visible_characters = old_len
|
dialogue.visible_characters = old_len
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,47 @@ extends Node
|
||||||
$Action8
|
$Action8
|
||||||
]
|
]
|
||||||
|
|
||||||
|
var base
|
||||||
|
|
||||||
## Script attached to transit buttons
|
## Script attached to transit buttons
|
||||||
const TRANSIT_BUTTON_SCRIPT = preload("res://scripts/Classes/Menu/transit_button.gd")
|
const TRANSIT_BUTTON_SCRIPT = preload("res://scripts/Classes/Menu/transit_button.gd")
|
||||||
|
## Buy/Sell item trigger
|
||||||
|
const BUY_SELL_ITEM = "BUY_SELL_ITEM"
|
||||||
|
## Buy/Sell button placeholder
|
||||||
|
const BASE_BUY_SELL = "BASE_BUY_SELL"
|
||||||
|
## Null button ID
|
||||||
|
const NULL = "NULL"
|
||||||
|
|
||||||
|
## Menu which is loaded on ready
|
||||||
@export var menu: Menu = null
|
@export var menu: Menu = null
|
||||||
|
|
||||||
|
## Is base buying from player or vice versa
|
||||||
|
var buy: bool = false
|
||||||
|
## How many buy/sell options are available
|
||||||
|
var buy_sell_options: int = -1
|
||||||
|
## Which buy/sell tab should be opened (tab holds 6 items)
|
||||||
|
var buy_sell_tab: int = 0
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
load_menu()
|
load_menu()
|
||||||
|
get_tree().create_timer(0.05).timeout.connect(post_ready)
|
||||||
|
|
||||||
|
func post_ready():
|
||||||
|
base = get_parent().get_parent().get_parent().base
|
||||||
|
|
||||||
## Called when menu is changed
|
## Called when menu is changed
|
||||||
func load_menu():
|
func load_menu():
|
||||||
|
var format = {}
|
||||||
# iterating through all actions
|
# iterating through all actions
|
||||||
for i in range(len(menu.item_ids)):
|
for i in range(len(menu.item_ids)):
|
||||||
|
match menu.item_ids[i]:
|
||||||
|
BASE_BUY_SELL:
|
||||||
|
if i <= buy_sell_options:
|
||||||
|
var list = base.items_on_buy if buy else base.items_on_sell
|
||||||
|
format["item_id"] = i + buy_sell_tab * 6
|
||||||
|
format["item_name"] = tr(list[i - 1 + buy_sell_tab * 6].name)
|
||||||
|
menu.item_ids[i] = BUY_SELL_ITEM
|
||||||
|
|
||||||
# disconnect previous action
|
# disconnect previous action
|
||||||
if actions[i] is TransitButton:
|
if actions[i] is TransitButton:
|
||||||
actions[i].button_up.disconnect(transit_menu)
|
actions[i].button_up.disconnect(transit_menu)
|
||||||
|
|
@ -31,7 +60,7 @@ func load_menu():
|
||||||
actions[i].button_up.disconnect(actions[i].action)
|
actions[i].button_up.disconnect(actions[i].action)
|
||||||
# disconnect previous script
|
# disconnect previous script
|
||||||
actions[i].set_script(null)
|
actions[i].set_script(null)
|
||||||
actions[i].text = menu.item_ids[i]
|
actions[i].text = tr(menu.item_ids[i]).format(format)
|
||||||
# assign new script
|
# assign new script
|
||||||
match menu.item_actions[i]:
|
match menu.item_actions[i]:
|
||||||
Menu.Action.TransitAction:
|
Menu.Action.TransitAction:
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@ BASE_FETCH_BUY_RECEIVED,I would like to buy something\nWe are selling:\n[ol]{sel
|
||||||
BASE_FETCH_SELL_LOCAL,"Ask, what they buy","Спросить, что они покупают"
|
BASE_FETCH_SELL_LOCAL,"Ask, what they buy","Спросить, что они покупают"
|
||||||
BASE_FETCH_SELL_RECEIVED,I have some items to sell\nWe can buy:\n[ol]{buy_list}[/ol]\n> ,У меня есть кое-что на продажу\nМы готовы купить:\n[ol]{buy_list}[/ol]\n>
|
BASE_FETCH_SELL_RECEIVED,I have some items to sell\nWe can buy:\n[ol]{buy_list}[/ol]\n> ,У меня есть кое-что на продажу\nМы готовы купить:\n[ol]{buy_list}[/ol]\n>
|
||||||
BASE_FETCH_PRICE_ITEM,[img=26x26]{item_img}[/img]{item_name} — {item_price},[img=26x26]{item_img}[/img]{item_name} — {item_price}
|
BASE_FETCH_PRICE_ITEM,[img=26x26]{item_img}[/img]{item_name} — {item_price},[img=26x26]{item_img}[/img]{item_name} — {item_price}
|
||||||
BASE_FETCH_BUY_CANCEL_LOCAL,Buy nothing,Ничего не покупать
|
BASE_FETCH_BUY_SELL_CANCEL_LOCAL,Buy nothing,Ничего не покупать
|
||||||
BASE_FETCH_BUY_CANCEL_RECEIVED,I changed my mind\nErm...Fine...\nAnything else?\n> ,Я передумал\nЧто ж...Ладно...\nЧто-то ещё?\n>
|
BASE_FETCH_BUY_SELL_CANCEL_RECEIVED,I changed my mind\nErm...Fine...\nAnything else?\n> ,Я передумал\nЧто ж...Ладно...\nЧто-то ещё?\n>
|
||||||
BASE_FETCH_SELL_CANCEL_LOCAL,Sell nothing,Ничего не продавать
|
BASE_BUY_SELL, ,
|
||||||
BASE_FETCH_SELL_CANCEL_RECEIVED,I changed my mind\nErm...Fine...\nAnything else?\n> ,Я передумал\nЧто ж...Ладно...\nЧто-то ещё?\n>
|
BASE_BUY_SELL_NEXT,Next tab,Следующая вкладка
|
||||||
|
BASE_BUY_SELL_PREV,Previous tab,Предыдущая вкладка
|
||||||
|
BUY_SELL_ITEM,{item_id}. {item_name},{item_id}. {item_name}
|
||||||
NULL, ,
|
NULL, ,
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue