From aafa9e7784078af379068cd20e77ec8f1992c282 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 29 Nov 2016 19:15:58 +0100 Subject: doc.entry_builders.text_and_gallery --- init.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'init.lua') 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 -- cgit v1.2.3