mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-07-04 13:08:04 +02:00
diffrent handling for formspec versions 2 and 1 (2 is pretty ok; 1 is ugly and barely usable)
This commit is contained in:
parent
b455321528
commit
e950cdc1f0
@ -297,7 +297,7 @@ yl_speak_up.add_edit_button_fs_talkdialog = function(formspec, h, button_name, t
|
|||||||
return h
|
return h
|
||||||
end
|
end
|
||||||
-- there has to be more room for the up and down arrows
|
-- there has to be more room for the up and down arrows
|
||||||
button_dimensions = "1.2,"..(h+1)..";52.8,0.9;"
|
button_dimensions = "1.2,"..(h+1)..";52.3,0.9;"
|
||||||
label_start_pos = "1.4"
|
label_start_pos = "1.4"
|
||||||
end
|
end
|
||||||
h = h + 1
|
h = h + 1
|
||||||
@ -464,12 +464,16 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
|||||||
owner_info = "\n\n(owned by "..minetest.formspec_escape(yl_speak_up.npc_owner[ n_id ])..")"
|
owner_info = "\n\n(owned by "..minetest.formspec_escape(yl_speak_up.npc_owner[ n_id ])..")"
|
||||||
end
|
end
|
||||||
|
|
||||||
local fs_version = "1"
|
local fs_version = 1
|
||||||
if formspec_v >= 4 then
|
if formspec_v >= 4 then
|
||||||
fs_version = "3"
|
fs_version = 3
|
||||||
|
elseif formspec_v >= 2 then
|
||||||
|
fs_version = 2
|
||||||
|
else
|
||||||
|
fs_version = 1
|
||||||
end
|
end
|
||||||
formspec = {
|
formspec = {
|
||||||
"formspec_version["..fs_version.."]",
|
"formspec_version["..tostring(fs_version).."]",
|
||||||
"size[57,33]",
|
"size[57,33]",
|
||||||
"position[0,0.45]",
|
"position[0,0.45]",
|
||||||
"anchor[0,0.45]",
|
"anchor[0,0.45]",
|
||||||
@ -513,10 +517,9 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
|||||||
portrait,
|
portrait,
|
||||||
"]",
|
"]",
|
||||||
}
|
}
|
||||||
|
|
||||||
if formspec_v >= 4 or true then
|
if formspec_v >= 4 or true then
|
||||||
-- add those things that only exist in formspec_v >= 4
|
-- add those things that only exist in formspec_v >= 4
|
||||||
if(fs_version ~= "1") then
|
if(fs_version > 2) then
|
||||||
table.insert(formspec, "style_type[button;bgcolor=#a37e45]")
|
table.insert(formspec, "style_type[button;bgcolor=#a37e45]")
|
||||||
table.insert(formspec, "style_type[button_exit;bgcolor=#a37e45]") -- Dialog
|
table.insert(formspec, "style_type[button_exit;bgcolor=#a37e45]") -- Dialog
|
||||||
-- table.insert(formspec, "background[-1,-1;22,25;yl_speak_up_bg_dialog2.png;false]")
|
-- table.insert(formspec, "background[-1,-1;22,25;yl_speak_up_bg_dialog2.png;false]")
|
||||||
@ -593,7 +596,7 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
|||||||
-- replace $NPC_NAME$ etc.
|
-- replace $NPC_NAME$ etc.
|
||||||
local t = minetest.formspec_escape(yl_speak_up.replace_vars_in_text(
|
local t = minetest.formspec_escape(yl_speak_up.replace_vars_in_text(
|
||||||
(alternate_text or active_dialog.d_text), dialog, pname))
|
(alternate_text or active_dialog.d_text), dialog, pname))
|
||||||
if(fs_version ~= "1") then
|
if(fs_version > 2) then
|
||||||
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
|
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
|
||||||
"hypertext", "0.2,5;19.6,17.8", "d_text",
|
"hypertext", "0.2,5;19.6,17.8", "d_text",
|
||||||
"<normal>"..t.."\n</normal>",
|
"<normal>"..t.."\n</normal>",
|
||||||
@ -609,17 +612,35 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
|||||||
end
|
end
|
||||||
|
|
||||||
local pname_for_old_fs = nil
|
local pname_for_old_fs = nil
|
||||||
if(fs_version ~= "1") then
|
if(fs_version > 2) then
|
||||||
table.insert(formspec, "scrollbaroptions[min=0;max=14;smallstep=1;largestep=2;arrows=show]")
|
table.insert(formspec, "scrollbaroptions[min=0;max=14;smallstep=1;largestep=2;arrows=show]")
|
||||||
table.insert(formspec, "scrollbar[0.2,24.2;0.2,7;vertical;scr0;0]")
|
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]")
|
table.insert(formspec, "scroll_container[0,24;56,7;scr0;vertical;1]")
|
||||||
else
|
else
|
||||||
|
if(fs_version < 2) then
|
||||||
|
table.insert(formspec,
|
||||||
|
"box[0.3,20;19,2.6;red]"..
|
||||||
|
"label[0.7,20.3;"..yl_speak_up.text_version_warning.."]")
|
||||||
|
-- The up and down buttons are microscopic. Offer some (still small)
|
||||||
|
-- additional text buttons so that players have a chance to hit them.
|
||||||
|
table.insert(formspec, "button[49,22.8;6,0.9;button_down;^ Scroll Up ^]")
|
||||||
|
table.insert(formspec, "button[49,31.8;6,0.9;button_up;v Scroll Down v]")
|
||||||
|
end
|
||||||
-- old formspec versions need to remember somewhere extern how far the player scrolled
|
-- old formspec versions need to remember somewhere extern how far the player scrolled
|
||||||
pname_for_old_fs = pname
|
pname_for_old_fs = pname
|
||||||
yl_speak_up.speak_to[pname_for_old_fs].counter = 1
|
yl_speak_up.speak_to[pname_for_old_fs].counter = 1
|
||||||
table.insert(formspec, "container[0,24]")
|
table.insert(formspec, "container[0,24]")
|
||||||
table.insert(formspec, "button[0.1,0;1,3;button_down;^\nU\np]")
|
if(fs_version < 2) then
|
||||||
table.insert(formspec, "button[0.1,3.2;1,4.5;button_up;D\no\nw\nn\nv]")
|
-- very small, ugly, and difficult to hit
|
||||||
|
table.insert(formspec, "button[0.1,0;1,0.9;button_down;^]")
|
||||||
|
table.insert(formspec, "button[0.1,7.0;1,0.9;button_up;v]")
|
||||||
|
else
|
||||||
|
-- somewhat larger and quite usable (v2 is pretty ok)
|
||||||
|
table.insert(formspec, "button[0.1,0;1,3;button_down;^\nU\np]")
|
||||||
|
table.insert(formspec, "button[0.1,3.2;1,4.5;button_up;D\no\nw\nn\nv]")
|
||||||
|
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
|
||||||
end
|
end
|
||||||
h = -0.8
|
h = -0.8
|
||||||
|
|
||||||
@ -890,7 +911,7 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
|||||||
yl_speak_up.message_button_option_exit,
|
yl_speak_up.message_button_option_exit,
|
||||||
true, nil, true, pname_for_old_fs) -- button_exit
|
true, nil, true, pname_for_old_fs) -- button_exit
|
||||||
|
|
||||||
if(fs_version ~= "1") then
|
if(fs_version > 2) then
|
||||||
table.insert(formspec, "scroll_container_end[]")
|
table.insert(formspec, "scroll_container_end[]")
|
||||||
else
|
else
|
||||||
table.insert(formspec, "container_end[]")
|
table.insert(formspec, "container_end[]")
|
||||||
|
Loading…
Reference in New Issue
Block a user