improved scrolling (at least for formspec version 3)
This commit is contained in:
parent
8f3a788987
commit
d36ab58a8e
@ -670,7 +670,7 @@ yl_speak_up.get_fs_action_text_input = function(player, param)
|
||||
|
||||
-- do not offer edit_mode in the trade formspec because it makes no sense there;
|
||||
return yl_speak_up.show_fs_decorated(pname, nil, h, alternate_text, "",
|
||||
table.concat(formspec, "\n"), nil)
|
||||
table.concat(formspec, "\n"), nil, h)
|
||||
|
||||
--[[ old version with extra formspec
|
||||
return --"size[12.0,4.5]"..
|
||||
|
@ -21,8 +21,8 @@ minetest.register_chatcommand( 'npc_talk_style', {
|
||||
minetest.chat_send_player(pname, "This command sets your formspec version "..
|
||||
"for the yl_speak_up NPC to value <version>.\n"..
|
||||
" Version 1: For very old clients. Not recommended.\n"..
|
||||
" Version 2: Adds extra scroll buttons. Perhaps you like this more.\n"..
|
||||
" Version 3: Default version.")
|
||||
" Version 2: Adds extra scroll buttons.\n"..
|
||||
" Version 3: Default (recommended) version.")
|
||||
end
|
||||
minetest.chat_send_player(pname, "Your formspec version for the yl_speak_up NPC "..
|
||||
"has been set to version "..tostring(yl_speak_up.fs_version[pname])..
|
||||
@ -148,7 +148,8 @@ yl_speak_up.show_fs_decorated = function(pname, edit_mode, h,
|
||||
alternate_text,
|
||||
add_this_to_left_window,
|
||||
add_this_to_bottom_window,
|
||||
active_dialog)
|
||||
active_dialog,
|
||||
h)
|
||||
if(not(pname)) then
|
||||
return ""
|
||||
end
|
||||
@ -260,11 +261,23 @@ yl_speak_up.show_fs_decorated = function(pname, edit_mode, h,
|
||||
table.insert(formspec, add_this_to_left_window)
|
||||
|
||||
local pname_for_old_fs = nil
|
||||
if(fs_version > 2) then
|
||||
table.insert(formspec, "scrollbaroptions[min=0;max=14;smallstep=1;largestep=2;arrows=show]")
|
||||
|
||||
-- is there any need to allow scrolling?
|
||||
local allow_scrolling = true
|
||||
-- in case of older formspec versions: it already does look pretty ugly; there
|
||||
-- is no point in checking there if we can scroll or not
|
||||
if(fs_version > 2 and h + 1 < yl_speak_up.max_number_of_buttons) then
|
||||
allow_scrolling = false
|
||||
end
|
||||
|
||||
if(allow_scrolling and fs_version > 2) then
|
||||
local max_scroll = math.ceil(h - yl_speak_up.max_number_of_buttons) + 1
|
||||
table.insert(formspec, "scrollbaroptions[min=0;max="..tostring(max_scroll)..
|
||||
";smallstep=1;largestep=2;arrows=show".. --]")
|
||||
";thumbsize="..tostring(math.ceil(h/yl_speak_up.max_number_of_buttons)).."]")
|
||||
table.insert(formspec, "scrollbar[0.2,24.2;0.2,7;vertical;scr0;0]")
|
||||
table.insert(formspec, "scroll_container[0,24;56,7;scr0;vertical;1]")
|
||||
else
|
||||
elseif(allow_scrolling) then
|
||||
if(fs_version < 2) then
|
||||
-- if the player has an older formspec version
|
||||
minetest.log( "info",
|
||||
@ -292,6 +305,8 @@ yl_speak_up.show_fs_decorated = function(pname, edit_mode, h,
|
||||
table.insert(formspec, "button[53.5,0;1,3;button_down;^\nU\np]")
|
||||
table.insert(formspec, "button[53.5,3.2;1,4.5;button_up;D\no\nw\nn\nv]")
|
||||
end
|
||||
else
|
||||
table.insert(formspec, "container[0,24]")
|
||||
end
|
||||
|
||||
table.insert(formspec, add_this_to_bottom_window)
|
||||
@ -302,7 +317,7 @@ yl_speak_up.show_fs_decorated = function(pname, edit_mode, h,
|
||||
yl_speak_up.message_button_option_exit,
|
||||
true, nil, true, pname_for_old_fs) -- button_exit
|
||||
|
||||
if(fs_version > 2) then
|
||||
if(allow_scrolling and fs_version > 2) then
|
||||
table.insert(formspec, "scroll_container_end[]")
|
||||
else
|
||||
table.insert(formspec, "container_end[]")
|
||||
|
@ -741,5 +741,5 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
||||
|
||||
return yl_speak_up.show_fs_decorated(pname, edit_mode, h, alternate_text,
|
||||
left_window_fs, bottom_window_fs,
|
||||
active_dialog)
|
||||
active_dialog, h)
|
||||
end
|
||||
|
@ -209,7 +209,7 @@ yl_speak_up.get_fs_trade_list = function(player, show_dialog_option_trades)
|
||||
"label[1,1;Sorry. There are currently no offers available.]")
|
||||
end
|
||||
|
||||
-- kein edit_mode beim trade-formspec da nicht sinnvoll
|
||||
-- edit mode makes no sense here in the trade list
|
||||
return yl_speak_up.show_fs_decorated(pname, nil, h, alternate_text, "",
|
||||
table.concat(formspec, "\n"), nil)
|
||||
table.concat(formspec, "\n"), nil, h)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user