cur_page = 1
end
- local formspec = {
- "size[12,7;true]",
- "position[0.5,0.55]",
- "field[0.2,0.1;7.8,1;search_string;;", core.formspec_escape(search_string), "]",
- "field_close_on_enter[search_string;false]",
- "button[7.7,-0.2;2,1;search;", fgettext("Search"), "]",
- "dropdown[9.7,-0.1;2.4;type;",
- table.concat(filter_types_titles, ","),
- ";",
- filter_type,
- "]",
- -- "textlist[0,1;2.4,5.6;a;",
- -- table.concat(taglist, ","),
- -- "]"
- }
+ local formspec
+ if #store.packages > 0 then
+ formspec = {
+ "size[12,7;true]",
+ "position[0.5,0.55]",
+ "field[0.2,0.1;7.8,1;search_string;;",
+ core.formspec_escape(search_string), "]",
+ "field_close_on_enter[search_string;false]",
+ "button[7.7,-0.2;2,1;search;",
+ fgettext("Search"), "]",
+ "dropdown[9.7,-0.1;2.4;type;",
+ table.concat(filter_types_titles, ","),
+ ";", filter_type, "]",
+ -- "textlist[0,1;2.4,5.6;a;",
+ -- table.concat(taglist, ","), "]",
+
+ -- Page nav buttons
+ "container[0,",
+ num_per_page + 1.5, "]",
+ "button[-0.1,0;3,1;back;",
+ fgettext("Back to Main Menu"), "]",
+ "button[7.1,0;1,1;pstart;<<]",
+ "button[8.1,0;1,1;pback;<]",
+ "label[9.2,0.2;",
+ tonumber(cur_page), " / ",
+ tonumber(pages), "]",
+ "button[10.1,0;1,1;pnext;>]",
+ "button[11.1,0;1,1;pend;>>]",
+ "container_end[]",
+ }
+ else
+ formspec = {
+ "size[12,7;true]",
+ "position[0.5,0.55]",
+ "label[4,3;No packages could be retrieved]",
+ "button[-0.1,",
+ num_per_page + 1.5,
+ ";3,1;back;",
+ fgettext("Back to Main Menu"), "]",
+ }
+ end
local start_idx = (cur_page - 1) * num_per_page + 1
for i=start_idx, math.min(#store.packages, start_idx+num_per_page-1) do
-- image
formspec[#formspec + 1] = "image[-0.4,0;1.5,1;"
- formspec[#formspec + 1] = get_screenshot(package)
+ formspec[#formspec + 1] = core.formspec_escape(get_screenshot(package))
formspec[#formspec + 1] = "]"
-- title
formspec[#formspec + 1] = fgettext("Install")
formspec[#formspec + 1] = "]"
elseif package.installed_release < package.release then
- formspec[#formspec + 1] = "button[8.4,0;1.5,1;install_"
+ formspec[#formspec + 1] = "button[8.4,0;1.5,1;update_"
formspec[#formspec + 1] = tostring(i)
formspec[#formspec + 1] = ";"
formspec[#formspec + 1] = fgettext("Update")
formspec[#formspec + 1] = "container_end[]"
end
- formspec[#formspec + 1] = "container[0,"
- formspec[#formspec + 1] = num_per_page + 1.5
- formspec[#formspec + 1] = "]"
- formspec[#formspec + 1] = "button[-0.1,0;3,1;back;"
- formspec[#formspec + 1] = fgettext("Back to Main Menu")
- formspec[#formspec + 1] = "]"
- formspec[#formspec + 1] = "button[7.1,0;1,1;pstart;<<]"
- formspec[#formspec + 1] = "button[8.1,0;1,1;pback;<]"
- formspec[#formspec + 1] = "label[9.2,0.2;"
- formspec[#formspec + 1] = tonumber(cur_page)
- formspec[#formspec + 1] = " / "
- formspec[#formspec + 1] = tonumber(pages)
- formspec[#formspec + 1] = "]"
- formspec[#formspec + 1] = "button[10.1,0;1,1;pnext;>]"
- formspec[#formspec + 1] = "button[11.1,0;1,1;pend;>>]"
- formspec[#formspec + 1] = "container_end[]"
-
- formspec[#formspec + 1] = "]"
return table.concat(formspec, "")
end