added frame to simple trade and made sold out indicator nicer

This commit is contained in:
Sokomine 2022-04-17 02:03:43 +02:00
parent ed17ea34fd
commit e04bc0c8d9
3 changed files with 36 additions and 6 deletions

View File

@ -310,3 +310,27 @@ yl_speak_up.show_fs_decorated = function(pname, edit_mode, h,
table.insert(formspec, "container_end[]")
return table.concat(formspec, "")
end
yl_speak_up.show_fs_simple_deco = function(size_x, size_y)
x_i = tostring(size_x - 1.5) -- "18.5"
x_a = tostring(size_x - 0.75) -- "19.25"
y_i = tostring(size_y - 1.25) --1.5) -- "21.5"
y_a = tostring(size_y - 0.5) --0.75) -- "22.25"
x_L = tostring(size_x + 0.8)
y_L = tostring(size_y + 0.8)
return "size["..tostring(size_x)..","..tostring(size_y).."]"..
"bgcolor[#00000000;false]"..
"style_type[button;bgcolor=#a37e45]"..
"style_type[button_exit;bgcolor=#a37e45]"..
"background[0,0;"..tostring(size_x)..","..tostring(size_y+0.25)..
";yl_speak_up_bg_dialog.png;false]"..
"image[-0.25,-0.25;1,1;yl_speak_up_bg_dialog_tl.png]"..
"image[-0.25,"..y_a..";1,1;yl_speak_up_bg_dialog_bl.png]"..
"image["..x_a..",-0.25;1,1;yl_speak_up_bg_dialog_tr.png]"..
"image["..x_a..","..y_a..";1,1;yl_speak_up_bg_dialog_br.png]"..
"image[-0.25,0.5;1,"..y_L..";yl_speak_up_bg_dialog_hl.png]"..
"image["..x_a..",0.5;1,"..y_L..";yl_speak_up_bg_dialog_hr.png]"..
"image[0.5,-0.25;"..x_L..",1;yl_speak_up_bg_dialog_vt.png]"..
"image[0.5,"..y_a..";"..x_L..",1;yl_speak_up_bg_dialog_vb.png]"
end

View File

@ -86,8 +86,8 @@ yl_speak_up.get_fs_trade_list = function(player, show_dialog_option_trades)
local alternate_text = " I can offer you these trades.\n\n"..
"Select one trade and then choose \"buy\" to actually buy something."..
"\n\nThere may be more trades then those shown in the first row. Please "..
"look at all my offers [that is, scroll down a bit]!"..
"\n\nThere may be more trades then those shown in the first row."..
"\nPlease look at all my offers [that is, scroll down a bit]!"..
"\n\n[$NPC_NAME$ looks expectantly at you.]"
local pname_for_old_fs = yl_speak_up.get_pname_for_old_fs(pname)
@ -129,11 +129,12 @@ yl_speak_up.get_fs_trade_list = function(player, show_dialog_option_trades)
if(sold_out) then
color = "#663333"
-- still needs to contain kstr so that each button has a diffrent text
kstr = "sold out "..kstr
-- kstr = "sold out "..kstr
end
table.insert(formspec,
"container["..tostring(0.5+(col*4.5))..","..
tostring(0.3+(row*6)).."]"..
"style_type[button;bgcolor=#FF4444]"..
"box[0,0;4.2,5.6;"..color.."]"..
"item_image_button[1.0,0.2;3,3;"..
tostring(v.buy[1])..";"..kstr..";]"..
@ -143,7 +144,9 @@ yl_speak_up.get_fs_trade_list = function(player, show_dialog_option_trades)
-- to the same result) just above
tostring(v.pay[1])..";"..kstr.."_;]")
if(sold_out) then
table.insert(formspec, "label[0,1.9;Sold out]\ncontainer_end[]")
-- table.insert(formspec, "label[0,1.9;Sold out]\ncontainer_end[]")
table.insert(formspec, "button[0,1.0;4.3,1.0;"..kstr.."__;Sold out]"..
"\ncontainer_end[]")
else
-- show the price label only when the offer is in stock
table.insert(formspec, "label[0,1.9;->]"..
@ -157,6 +160,8 @@ yl_speak_up.get_fs_trade_list = function(player, show_dialog_option_trades)
end
end
-- set button background color back to golden/brownish
table.insert(formspec, "style_type[button;bgcolor=#a37e45]")
h = (row+1) * 6 - 0.6
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
"show_inventory",

View File

@ -564,7 +564,8 @@ yl_speak_up.get_fs_trade_simple = function(player, trade_id)
end
-- the common formspec, shared by actual trade and configuration
-- no listring here as that would make things more complicated
local formspec = "size[8.5,8]"..
local formspec = -- "size[8.5,8]"..
yl_speak_up.show_fs_simple_deco(8.5, 8)..
"label[4.35,0.7;"..minetest.formspec_escape(trade.npc_name).." sells:]"..
"list[current_player;main;0.2,3.85;8,1;]"..
"list[current_player;main;0.2,5.08;8,3;8]"
@ -589,7 +590,7 @@ yl_speak_up.get_fs_trade_simple = function(player, trade_id)
-- allow delete for trades in trade list even if not in edit mode
-- (entering edit mode for that would be too much work)
formspec = formspec..
"button[0.2,1.6;1.2,0.9;delete_trade_simple;Delete]"..
"button[0.2,2.0;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).]"