Remove scrollbar from trader form

Use image buttons instead of scrollbar
master
shivajiva101 2020-09-16 15:47:16 +01:00 committed by GitHub
parent af3a5e6c06
commit 63baa47295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 14 deletions

View File

@ -63,12 +63,8 @@ local function build_form(name, items)
local frm = { local frm = {
"formspec_version[3]", "formspec_version[3]",
"size[6,5.5]", "size[6,5.5]",
"scrollbaroptions[min=0;max=", "image_button[5,0.5;0.5,0.5;eggwars_up.png;up;]",
(#items * 8) + (#items - 1), -- qty x height + space "image_button[5,4.4;0.5,0.5;eggwars_down.png;down;]",
";smallstep=44;largestep=44;thumbsize=1;arrows=default]",
"scrollbar[5,0.5;0.5,4.3;vertical;msb;",
context[name].val,
"]",
"container[0.5,", "container[0.5,",
context[name].y, context[name].y,
"]", "]",
@ -147,15 +143,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return return
end end
end end
-- scrollbar -- scroll
if formname == TF and fields.msb then if formname == TF then
local res = minetest.explode_scrollbar_event(fields.msb) local y = context[name].y
if res.type == "CHG" then local limit = -4.4 * 5 -- height * number of pages
local val = res.value if fields.up and y ~= 0 then
context[name].y = -val/10 y = y + 4.4
context[name].val = val context[name].y = y
minetest.show_formspec(name, TF, build_form(name, def.shop_items)) elseif fields.down and y > limit then
y = y - 4.4
context[name].y = y
end end
minetest.show_formspec(name, TF, build_form(name, def.shop_items))
end end
elseif formname == BF and fields.btn then elseif formname == BF and fields.btn then