Update Algae, Beds, and Fix display of mod documentations
This commit is contained in:
parent
1cdd518fe5
commit
a2565d93f3
@ -8,13 +8,13 @@ local S = minetest.get_translator("algae")
|
|||||||
-----Load documentation via doc_helper------------------------
|
-----Load documentation via doc_helper------------------------
|
||||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||||
local docpath = MP .. DIR_DELIM .. "doc"
|
local docpath = MP .. DIR_DELIM .. "doc"
|
||||||
doc.add_category("_aglae",
|
doc.add_category("algae",
|
||||||
{
|
{
|
||||||
name = "_algae",
|
name = S("_Algae_"),
|
||||||
description = "Algae Mod Documentation",
|
description = S("Algae Mod Documentation"),
|
||||||
build_formspec = doc.entry_builders.text_and_square_gallery,
|
build_formspec = doc.entry_builders.text_and_square_gallery,
|
||||||
})
|
})
|
||||||
doc.build_entries(docpath, "_algae")
|
doc.build_entries(docpath, "algae")
|
||||||
|
|
||||||
------Registrations--------
|
------Registrations--------
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
-----Load documentation via doc_helper------------------------
|
-----Load documentation via doc_helper------------------------
|
||||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||||
local docpath = MP .. DIR_DELIM .. "doc"
|
local docpath = MP .. DIR_DELIM .. "doc"
|
||||||
doc.add_category("_beds",
|
doc.add_category("beds",
|
||||||
{
|
{
|
||||||
name = "_beds",
|
name = "_Beds_",
|
||||||
description = "Bed Documentation",
|
description = "Bed Documentation",
|
||||||
build_formspec = doc.entry_builders.text_and_square_gallery,
|
build_formspec = doc.entry_builders.text_and_square_gallery,
|
||||||
})
|
})
|
||||||
doc.build_entries(docpath, "_beds")
|
doc.build_entries(docpath, "beds")
|
@ -479,6 +479,25 @@ doc.entry_builders.text_and_gallery = function(data, playername)
|
|||||||
return formstring
|
return formstring
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Scrollable freeform text with an optional standard gallery (3 rows, 1:1 aspect ratio)
|
||||||
|
doc.entry_builders.text_and_square_gallery = function(data, playername)
|
||||||
|
-- How much height the image gallery “steals” from the text widget
|
||||||
|
local stolen_height = 0
|
||||||
|
local formstring = ""
|
||||||
|
-- Only add the gallery if images are in the data, otherwise, the text widget gets all of the space
|
||||||
|
if data.images ~= nil then
|
||||||
|
local gallery
|
||||||
|
gallery, stolen_height = doc.widgets.gallery(data.images, playername, nil, doc.FORMSPEC.ENTRY_END_Y + 0.2, 1, doc.FORMSPEC.ENTRY_WIDTH*3/5, 5, nil, false, nil)
|
||||||
|
formstring = formstring .. gallery
|
||||||
|
end
|
||||||
|
formstring = formstring .. doc.widgets.text(data.text,
|
||||||
|
doc.FORMSPEC.ENTRY_START_X,
|
||||||
|
doc.FORMSPEC.ENTRY_START_Y,
|
||||||
|
doc.FORMSPEC.ENTRY_WIDTH - 0.4,
|
||||||
|
doc.FORMSPEC.ENTRY_HEIGHT - stolen_height)
|
||||||
|
return formstring
|
||||||
|
end
|
||||||
|
|
||||||
doc.widgets = {}
|
doc.widgets = {}
|
||||||
|
|
||||||
-- Scrollable freeform text
|
-- Scrollable freeform text
|
||||||
@ -508,7 +527,7 @@ end
|
|||||||
|
|
||||||
-- Image gallery
|
-- Image gallery
|
||||||
-- Currently, only one gallery per entry is supported. TODO: Add support for multiple galleries in an entry (low priority)
|
-- Currently, only one gallery per entry is supported. TODO: Add support for multiple galleries in an entry (low priority)
|
||||||
doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, rows, align_left, align_top)
|
doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, rows, align_left, align_top, button_width)
|
||||||
if playername == nil then return nil end -- emergency exit
|
if playername == nil then return nil end -- emergency exit
|
||||||
|
|
||||||
local formstring = ""
|
local formstring = ""
|
||||||
@ -542,7 +561,7 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width,
|
|||||||
if aspect_ratio == nil then aspect_ratio = (2/3) end
|
if aspect_ratio == nil then aspect_ratio = (2/3) end
|
||||||
local pos = 0
|
local pos = 0
|
||||||
local totalimagewidth, iw, ih
|
local totalimagewidth, iw, ih
|
||||||
local bw = 0.5
|
local bw = button_width or 0.5
|
||||||
local buttonoffset = 0
|
local buttonoffset = 0
|
||||||
if #imagedata > rows then
|
if #imagedata > rows then
|
||||||
totalimagewidth = width - bw*2
|
totalimagewidth = width - bw*2
|
||||||
@ -562,6 +581,7 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width,
|
|||||||
end
|
end
|
||||||
formstring = formstring .. "tooltip[doc_button_gallery_prev;"..tt.."]"
|
formstring = formstring .. "tooltip[doc_button_gallery_prev;"..tt.."]"
|
||||||
end
|
end
|
||||||
|
buttonoffset = bw
|
||||||
if (imageindex + rows) <= #imagedata then
|
if (imageindex + rows) <= #imagedata then
|
||||||
local rightx = buttonoffset + (x + rows * iw)
|
local rightx = buttonoffset + (x + rows * iw)
|
||||||
formstring = formstring .. "button["..rightx..","..y..";"..bw..","..ih..";doc_button_gallery_next;"..F(">").."]"
|
formstring = formstring .. "button["..rightx..","..y..";"..bw..","..ih..";doc_button_gallery_next;"..F(">").."]"
|
||||||
@ -572,7 +592,6 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width,
|
|||||||
end
|
end
|
||||||
formstring = formstring .. "tooltip[doc_button_gallery_next;"..tt.."]"
|
formstring = formstring .. "tooltip[doc_button_gallery_next;"..tt.."]"
|
||||||
end
|
end
|
||||||
buttonoffset = bw
|
|
||||||
else
|
else
|
||||||
totalimagewidth = width
|
totalimagewidth = width
|
||||||
iw = totalimagewidth / rows
|
iw = totalimagewidth / rows
|
||||||
@ -593,7 +612,6 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width,
|
|||||||
formstring = formstring .. "label["..nx..","..ny..";"..i.."]"
|
formstring = formstring .. "label["..nx..","..ny..";"..i.."]"
|
||||||
pos = pos + 1
|
pos = pos + 1
|
||||||
end
|
end
|
||||||
local bw, bh
|
|
||||||
|
|
||||||
return formstring, ih
|
return formstring, ih
|
||||||
end
|
end
|
||||||
|
@ -26,34 +26,4 @@ doc.build_entries = function(path, category)
|
|||||||
util.create_entries(modname, path, filename, category) --generates entries for given category
|
util.create_entries(modname, path, filename, category) --generates entries for given category
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Scrollable freeform text with an optional standard gallery (3 rows, 1:1 aspect ratio)
|
|
||||||
doc.entry_builders.text_and_square_gallery = function(data, playername)
|
|
||||||
-- How much height the image gallery “steals” from the text widget
|
|
||||||
local stolen_height = 0
|
|
||||||
local formstring = ""
|
|
||||||
-- Only add the gallery if images are in the data, otherwise, the text widget gets all of the space
|
|
||||||
if data.images ~= nil then
|
|
||||||
local gallery
|
|
||||||
gallery, stolen_height = doc.widgets.gallery(data.images, playername, nil, doc.FORMSPEC.ENTRY_END_Y + 0.2, 1, nil, nil, nil, false)
|
|
||||||
formstring = formstring .. gallery
|
|
||||||
end
|
|
||||||
formstring = formstring .. doc.widgets.text(data.text,
|
|
||||||
doc.FORMSPEC.ENTRY_START_X,
|
|
||||||
doc.FORMSPEC.ENTRY_START_Y,
|
|
||||||
doc.FORMSPEC.ENTRY_WIDTH - 0.4,
|
|
||||||
doc.FORMSPEC.ENTRY_HEIGHT - stolen_height)
|
|
||||||
return formstring
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local docpath = MP .. DIR_DELIM .. "doc"
|
|
||||||
doc.add_category("fun",
|
|
||||||
{
|
|
||||||
name = "fun",
|
|
||||||
description = "FUN!",
|
|
||||||
build_formspec = doc.entry_builders.text_and_square_gallery,
|
|
||||||
})
|
|
||||||
doc.build_entries(docpath, "fun")
|
|
@ -85,8 +85,8 @@ util.create_entries = function(modname, folder_path, filename, category)
|
|||||||
table.insert(imagelist, {image=img})
|
table.insert(imagelist, {image=img})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
doc.add_entry(category, modname.."_"..filename_noext, {
|
doc.add_entry(category, filename_noext, {
|
||||||
name = minetest.get_translator(modname)(modname).."_"..filename_noext, --Modname is assumed to the be translator for everything that's not covered by doc
|
name = S(filename_noext),
|
||||||
data = {
|
data = {
|
||||||
text = document,
|
text = document,
|
||||||
images = imagelist,
|
images = imagelist,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user