From e04bc0c8d9e0ba5dae8fca5560c91717f021975c Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sun, 17 Apr 2022 02:03:43 +0200 Subject: [PATCH] added frame to simple trade and made sold out indicator nicer --- fs_decorated.lua | 24 ++++++++++++++++++++++++ trade_list.lua | 13 +++++++++---- trade_simple.lua | 5 +++-- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/fs_decorated.lua b/fs_decorated.lua index f800593..9738899 100644 --- a/fs_decorated.lua +++ b/fs_decorated.lua @@ -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 diff --git a/trade_list.lua b/trade_list.lua index 3ac919a..002b57c 100644 --- a/trade_list.lua +++ b/trade_list.lua @@ -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", diff --git a/trade_simple.lua b/trade_simple.lua index e09675f..9300504 100644 --- a/trade_simple.lua +++ b/trade_simple.lua @@ -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).]"