mirror of
https://github.com/TeTpaAka/quests.git
synced 2024-12-22 16:50:39 +01:00
Add manual word wrap
makes the quest info description read only.
This commit is contained in:
parent
58b0a3cf39
commit
9935a7d7c5
@ -87,17 +87,48 @@ function quests.create_config(playername, integrated)
|
|||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function wordwrap(text, linelength)
|
||||||
|
local lines = text:split("\n")
|
||||||
|
local ret = ""
|
||||||
|
for i = 1,#lines do
|
||||||
|
local line = lines[i]
|
||||||
|
while (#line > linelength) do
|
||||||
|
local split = false
|
||||||
|
local j = linelength
|
||||||
|
while (not split) do
|
||||||
|
if (string.sub(line, j, j) == " ") then
|
||||||
|
split = true
|
||||||
|
ret = ret .. string.sub(line, 1, j) .. "\n"
|
||||||
|
line = string.sub(line, j + 1)
|
||||||
|
end
|
||||||
|
if (j <= 1) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
j = j - 1
|
||||||
|
end
|
||||||
|
if (not split) then
|
||||||
|
ret = ret .. string.sub(line, 1, linelength) .. "\n"
|
||||||
|
line = string.sub(line, linelength);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ret = ret .. line .. "\n"
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
-- construct the info formspec
|
-- construct the info formspec
|
||||||
function quests.create_info(playername, questname, integrated)
|
function quests.create_info(playername, questname, integrated)
|
||||||
local formspec = ""
|
local formspec = ""
|
||||||
if (not integrated) then
|
if (not integrated) then
|
||||||
formspec = formspec .. "size[7,6.5]"
|
formspec = formspec .. "size[9,6.5]"
|
||||||
end
|
end
|
||||||
formspec = formspec .. "label[0.5,0.5;"
|
formspec = formspec .. "label[0.5,0.5;"
|
||||||
|
|
||||||
if (questname) then
|
if (questname) then
|
||||||
formspec = formspec .. quests.registered_quests[questname].title .. "]" ..
|
formspec = formspec .. quests.registered_quests[questname].title .. "]" ..
|
||||||
"textarea[.5,1.5;6,4.5;quests_info_description;;" .. quests.registered_quests[questname].description .. "]"
|
"box[.4,1.5;8.2,4.5;#999999]" ..
|
||||||
|
"label[.5,1.5;" ..
|
||||||
|
wordwrap(quests.registered_quests[questname].description, 60) .. "]"
|
||||||
|
|
||||||
if (quests.formspec_lists[playername].tab == "1") then
|
if (quests.formspec_lists[playername].tab == "1") then
|
||||||
formspec = formspec .. "button[.5,6;3,.7;quests_info_abort;" .. S("Abort quest") .. "]"
|
formspec = formspec .. "button[.5,6;3,.7;quests_info_abort;" .. S("Abort quest") .. "]"
|
||||||
|
Loading…
Reference in New Issue
Block a user