Swtich from tables to textareas for text display

This commit is contained in:
Wuzzy 2024-11-27 14:01:25 +01:00
parent 7b103e1f25
commit 0bc9d897b5

View File

@ -58,6 +58,14 @@ if(read==false) then
tutorial.state.last_diamond = false
end
local function text_box(caption, text)
return "label[0,-0.3;"..minetest.formspec_escape(S(caption)).."]"..
"box[-0.05,0.25;12,5.2;#000000FF]"..
"textarea[0.35,0.35;12,5.75;;;"..
minetest.formspec_escape(S(text))..
"]"
end
function tutorial.register_infosign(itemstringpart, caption, fulltext)
tutorial.captions[itemstringpart] = caption
minetest.register_node("tutorial:sign_"..itemstringpart, {
@ -80,9 +88,8 @@ function tutorial.register_infosign(itemstringpart, caption, fulltext)
local formspec = ""..
"size[12,6]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S(caption)).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;infosign_text;"..
"box[-0.05,0.25;12,5.7;#000000FF]"..
"textarea[0.35,0.35;12,5.7;;;"..
minetest.formspec_escape(S(fulltext))..
"]"..
"button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
@ -107,12 +114,7 @@ minetest.register_abm( {
end
local formspec = ""..
"size[12,6]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S(caption)).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;infosign_text;"..
minetest.formspec_escape(S(tutorial.texts[id]))..
"]"..
text_box(caption, tutorial.texts[id])..
"button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
meta:set_string("formspec", formspec)
meta:set_string("infotext", S("@1 (Right-click to read)", S(caption)))
@ -1329,12 +1331,7 @@ minetest.register_abm({
]]
function tutorial.show_default_dialog(name, caption, text)
local formspec = "size[12,6]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(caption).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;text_table;"..
minetest.formspec_escape(S(text))..
"]"..
text_box(caption, text)..
"button_exit[4.5,5.5;3,1;close;"..S("Close").."]"
minetest.show_formspec(name, "tutorial_dialog", formspec)
end
@ -1343,33 +1340,18 @@ minetest.register_on_joinplayer(function(player)
local formspec = nil
if(minetest.is_singleplayer() == false) then
formspec = "size[12,6]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S("Warning: You're not playing in singleplayer mode")).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;creative_text;"..
minetest.formspec_escape(S(tutorial.texts.notsingleplayer))..
"]"..
text_box(NS("Warning: You're not playing in singleplayer mode"), tutorial.texts.notsingleplayer)..
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
"button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
elseif(not map_editing and minetest.settings:get_bool("creative_mode")) then
formspec = "size[12,6]"..
"label[-0.15,-0.4;"..(minetest.formspec_escape(S("Warning: Creative mode is active"))).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;creative_text;"..
minetest.formspec_escape(S(tutorial.texts.creative))..
"]"..
text_box(NS("Warning: Creative mode is active"), tutorial.texts.creative)..
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
"button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
elseif(not map_editing and tutorial.state.intro_text == false) then
formspec = "size[12,6]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S("Introduction")).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;intro_text;"..
minetest.formspec_escape(S(tutorial.texts.intro))..
"]"..
text_box(NS("Introduction"), tutorial.texts.intro)..
"button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
tutorial.state.intro_text = true
end
@ -1454,7 +1436,7 @@ minetest.register_globalstep(function(dtime)
if(inv:contains_item("main", gold_stack)) then
tutorial.show_default_dialog(
name,
S("Gold ingots in the tutorial"),
NS("Gold ingots in the tutorial"),
tutorial.texts.first_gold
)
tutorial.state.first_gold = true
@ -1465,12 +1447,7 @@ minetest.register_globalstep(function(dtime)
local gold_stack = ItemStack("tutorial_default:gold_ingot "..tostring(tutorial.gold))
if(inv:contains_item("main", gold_stack)) then
local formspec = "size[12,6]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S("You've finished the tutorial!")).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;creative_text;"..
minetest.formspec_escape(S(tutorial.texts.last_gold))..
"]"..
text_box(NS("You've finished the tutorial!"), tutorial.texts.last_gold)..
"button_exit[0.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue")).."]"..
"button_exit[4.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"..
"button_exit[8.5,5.5;3,1;gotoend;"..minetest.formspec_escape(S("Go to Good-Bye room")).."]"
@ -1488,7 +1465,7 @@ minetest.register_globalstep(function(dtime)
if(inv:contains_item("main", diamond_stack)) then
tutorial.show_default_dialog(
name,
S("You found a hidden diamond!"),
NS("You found a hidden diamond!"),
tutorial.texts.first_diamond
)
tutorial.state.first_diamond = true
@ -1499,12 +1476,7 @@ minetest.register_globalstep(function(dtime)
local diamond_stack = ItemStack("tutorial_default:diamond "..tostring(tutorial.diamonds))
if(inv:contains_item("main", diamond_stack)) then
local formspec = "size[12,6]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S("You have collected all hidden diamonds!")).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;last_diamond_text;"..
minetest.formspec_escape(S(tutorial.texts.last_diamond))..
"]"..
text_box(NS("You have collected all hidden diamonds!"), tutorial.texts.last_diamond)..
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue")).."]"..
"button_exit[6.5,5.5;3,1;gotoend;"..minetest.formspec_escape(S("Go to Good-Bye room")).."]"
minetest.show_formspec(name, "tutorial_last_diamond", formspec)