diff options
author | Wuzzy <almikes@aol.com> | 2016-11-29 16:51:12 +0100 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2016-11-29 16:51:12 +0100 |
commit | 4d2b79732c62bf4b33c9262df295094591f1495e (patch) | |
tree | 2aadbc8c49244170219c68f994dc4270db78ca3c | |
parent | 330e83323c7c4d9b2084772790ab89227ce93a57 (diff) |
Scroll galleries pagewise
-rw-r--r-- | init.lua | 29 |
1 files changed, 20 insertions, 9 deletions
@@ -524,6 +524,7 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, local imageindex = doc.data.players[playername].galidx doc.data.players[playername].maxgalidx = #imagedata + doc.data.players[playername].galrows = rows if aspect_ratio == nil then aspect_ratio = (2/3) end local pos = 0 @@ -535,10 +536,21 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, iw = totalimagewidth / rows ih = iw * aspect_ratio formstring = formstring .. "button["..x..","..y..";"..bw..","..ih..";doc_button_gallery_prev;"..F("<").."]" - formstring = formstring .. "tooltip[doc_button_gallery_prev;"..F("Show previous image").."]" + local tt + if rows == 1 then + tt = F("Show previous image") + else + tt = F("Show previous gallery page") + end + formstring = formstring .. "tooltip[doc_button_gallery_prev;"..tt.."]" local rightx = buttonoffset + (x + rows * iw) formstring = formstring .. "button["..rightx..","..y..";"..bw..","..ih..";doc_button_gallery_next;"..F(">").."]" - formstring = formstring .. "tooltip[doc_button_gallery_next;"..F("Show next image").."]" + if rows == 1 then + tt = F("Show next image") + else + tt = F("Show next gallery page") + end + formstring = formstring .. "tooltip[doc_button_gallery_next;"..tt.."]" buttonoffset = bw else totalimagewidth = width @@ -1049,19 +1061,16 @@ function doc.process_form(player,formname,fields) end elseif fields["doc_button_gallery_prev"] then local cid, eid = doc.get_selection(playername) - doc.data.players[playername].galidx = doc.data.players[playername].galidx - 1 - if doc.data.players[playername].galidx <= 0 then - doc.data.players[playername].galidx = 1 + if doc.data.players[playername].galidx - doc.data.players[playername].galrows > 0 then + doc.data.players[playername].galidx = doc.data.players[playername].galidx - doc.data.players[playername].galrows end local formspec = doc.formspec_core(3)..doc.formspec_entry(cid, eid, playername) minetest.show_formspec(playername, "doc:entry", formspec) elseif fields["doc_button_gallery_next"] then local cid, eid = doc.get_selection(playername) - doc.data.players[playername].galidx = doc.data.players[playername].galidx + 1 - if doc.data.players[playername].galidx > doc.data.players[playername].maxgalidx then - doc.data.players[playername].galidx = doc.data.players[playername].maxgalidx + if doc.data.players[playername].galidx + doc.data.players[playername].galrows <= doc.data.players[playername].maxgalidx then + doc.data.players[playername].galidx = doc.data.players[playername].galidx + doc.data.players[playername].galrows end - local formspec = doc.formspec_core(3)..doc.formspec_entry(cid, eid, playername) minetest.show_formspec(playername, "doc:entry", formspec) end @@ -1091,6 +1100,8 @@ minetest.register_on_joinplayer(function(player) playerdata.galidx = 1 -- Maximum gallery index (index of last image in gallery) playerdata.maxgalidx = 1 + -- Number of rows in an gallery of the current entry + playerdata.galrows = 1 -- Table for persistant data playerdata.stored_data = {} -- Contains viewed entries |