made trade dialog more consistant for dialog option trades in edit mode or normal mode

This commit is contained in:
Sokomine 2021-06-02 16:57:33 +02:00
parent 33c79b4af0
commit e6f9dbac67

View File

@ -171,7 +171,7 @@ yl_speak_up.get_fs_add_trade_simple = function(player, trade_id)
delete_button = ""
end
return "size[8.5,8]"..
"label[4.35,0.7;"..minetest.formspec_escape(dialog.n_npc).." sells:]"..
"label[4.35,0.8;"..minetest.formspec_escape(dialog.n_npc).." sells:]"..
"list[current_player;main;0.2,3.85;8,1;]"..
"list[current_player;main;0.2,5.08;8,3;8]"..
-- show the second slot of the setup inventory in the detached player's inv
@ -554,42 +554,47 @@ yl_speak_up.get_fs_trade_simple = function(player, trade_id)
-- show edit button for the owner if in edit_mode
if(yl_speak_up.may_edit_npc(player, trade.n_id)) then
-- for trades as part of the results/effects: allow edit
if(not(trade.trade_is_trade_list)
and (yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id)) then
formspec = formspec..
"button[0.2,1.6;1.0,0.9;edit_trade_simple;Edit]"..
"tooltip[edit_trade_simple;Edit this trade. You can do so only "..
"if you can edit the NPC as such (i.e. own it).]"
local dialog = yl_speak_up.speak_to[pname].dialog
local tr = dialog.trades[ trade_id ]
-- offer button to show the edit options dialog if suitable
if( tr and tr.d_id and tr.o_id) then
formspec = formspec..
"button[0.2,-0.5;4.5,0.9;back_to_edit_options;"..
minetest.formspec_escape("Back to edit dialog "..
tostring(tr.d_id).." option "..
tostring(tr.o_id)).."]"..
"tooltip[back_to_edit_options;Go back to editing the option "..
"where this trade is located.]"
end
-- for trades in trade list: allow delete (new trades can easily be added)
-- allow delete for trades in trade list even if not in edit mode
-- (entering edit mode for that would be too much work)
elseif(trade.trade_is_trade_list) then
formspec = formspec..
"button[0.2,1.6;1.2,0.9;delete_trade_simple;Delete]"..
"tooltip[delete_trade_simple;Delete this trade. You can do so only "..
"if you can edit the NPC as such (i.e. own it).]"
else
formspec = formspec..
"button[0.2,1.6;1.2,0.9;delete_trade_simple;Delete]"..
"tooltip[delete_trade_simple;"..
"Delete this trade. You can do so only if\n"..
"you can edit the NPC as such (i.e. own it).]"
if(not(trade.trade_is_trade_list)) then
-- normal back button will lead to the talk dialog or edit option dialog;
-- add this second back button to go back to the list of all dialog option trades
formspec = formspec..
"button[0.2,1.0;2.0,0.9;show_trade_list_dialog_options;Back to list]"..
"tooltip[show_trade_list_dialog_options;"..
"tooltip[show_trade_list_dialog_options;"..
"Click here to get back to the list of all trades\n"..
"associated with dialog options (like this one).]"
local dialog = yl_speak_up.speak_to[pname].dialog
local tr = dialog.trades[ trade_id ]
if( tr and tr.d_id and tr.o_id) then
formspec = formspec..
"label[0.2,-0.3;This trade belongs to dialog "..
minetest.formspec_escape(tostring(tr.d_id)).." option "..
minetest.formspec_escape(tostring(tr.o_id))..".]"
end
end
end
-- the functionality of the back button depends on context
if(not(trade.trade_is_trade_list)) then
-- go back to the right dialog (or forward to the next one)
formspec = formspec..
-- "button[6.2,1.6;2.0,0.9;finished_trading;Back to talk]"..
"button[0.2,0.0;2.0,0.9;finished_trading;Back to talk]"..
"tooltip[finished_trading;Click here once you've traded enough with this "..
"NPC and want to get back to talking.]"
else
-- go back to the trade list
formspec = formspec.. "button[0.2,0.0;2.0,0.9;back_to_trade_list;Back to list]"..
"tooltip[back_to_trade_list;Click here once you've traded enough with this "..
"NPC and want to get back to the trade list.]"
end
local trade_possible_msg = "Status of trade: Unknown."
-- has the NPC room for the payment?
@ -640,21 +645,6 @@ yl_speak_up.get_fs_trade_simple = function(player, trade_id)
"free inventory space to store your purchase.]"
end
-- the functionality of the back button depends on context
if(not(trade.trade_is_trade_list)) then
-- go back to the right dialog (or forward to the next one)
formspec = formspec..
-- "button[6.2,1.6;2.0,0.9;finished_trading;Back to talk]"..
"button[0.2,0.0;2.0,0.9;finished_trading;Back to talk]"..
"tooltip[finished_trading;Click here once you've traded enough with this "..
"NPC and want to get back to talking.]"
else
-- go back to the trade list
formspec = formspec.. "button[0.2,0.0;2.0,0.9;back_to_trade_list;Back to list]"..
"tooltip[back_to_trade_list;Click here once you've traded enough with this "..
"NPC and want to get back to the trade list.]"
end
return formspec..
"label[2.5,0.0;Trading with "..minetest.formspec_escape(trade.npc_name).."]"..
"label[1.5,0.7;You pay:]"..