summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-11-29 19:15:58 +0100
committerWuzzy <almikes@aol.com>2016-11-29 19:15:58 +0100
commitaafa9e7784078af379068cd20e77ec8f1992c282 (patch)
tree09b9592f11fb6c839d294ac29e60cbfe91409514 /init.lua
parentc7eba913044fc2db021e87b433e01faa95165f60 (diff)
doc.entry_builders.text_and_gallery
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index fedfd88..325d15e 100644
--- a/init.lua
+++ b/init.lua
@@ -479,6 +479,26 @@ doc.entry_builders.text = function(data)
return formstring
end
+-- Scrollable freeform text with an optional standard gallery (3 rows, 3:2 aspect ratio)
+doc.entry_builders.text_and_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)
+ formstring = formstring .. gallery
+ end
+ formstring = formstring .. doc.widgets.text(data.text,
+ doc.FORMSPEC.ENTRY_START_X,
+ doc.FORMSPEC.ENTRY_START_Y + stolen_height,
+ doc.FORMSPEC.ENTRY_WIDTH - 0.2,
+ doc.FORMSPEC.ENTRY_HEIGHT - stolen_height)
+
+ return formstring
+end
+
doc.widgets = {}
local text_id = 1