]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - builtin/modstore.lua
Use engine.is_yes() in mainmenu
[dragonfireclient.git] / builtin / modstore.lua
index 73afc38995bb9012c4ad9628222e797718f12ced..2f967c9b16a2a50f248d4aad56b60762dc486603 100644 (file)
@@ -29,10 +29,8 @@ function modstore.init()
        
        modstore.modsperpage = 5
        
-       modstore.basetexturedir = engine.get_gamepath() .. DIR_DELIM .. ".." ..
-                                               DIR_DELIM .. "textures" .. DIR_DELIM .. "base" .. 
+       modstore.basetexturedir = engine.get_texturepath() .. DIR_DELIM .. "base" .. 
                                                DIR_DELIM .. "pack" .. DIR_DELIM
-       modstore.update_modlist()
        
        modstore.current_list = nil
        
@@ -118,7 +116,7 @@ function modstore.handle_buttons(current_tab,fields)
        
        if fields["btn_modstore_page_down"] then
                if modstore.current_list ~= nil and 
-                       modstore.current_list.page <modstore.current_list.pagecount then
+                       modstore.current_list.page <modstore.current_list.pagecount-1 then
                        modstore.current_list.page = modstore.current_list.page +1
                end
        end
@@ -143,7 +141,6 @@ function modstore.handle_buttons(current_tab,fields)
                        local fullurl = engine.setting_get("modstore_download_url") ..
                                                                moddetails.download_url
                        local modfilename = os.tempfolder() .. ".zip"
-                       print("Downloading mod from: " .. fullurl .. " to ".. modfilename)
                        
                        if engine.download_file(fullurl,modfilename) then
                        
@@ -172,10 +169,10 @@ function modstore.update_modlist()
                
        if modstore.modlist_unsorted.data ~= nil then
                modstore.modlist_unsorted.pagecount = 
-                       math.floor((#modstore.modlist_unsorted.data / modstore.modsperpage))
+                       math.ceil((#modstore.modlist_unsorted.data / modstore.modsperpage))
        else
                modstore.modlist_unsorted.data = {}
-               modstore.modlist_unsorted.pagecount = 0
+               modstore.modlist_unsorted.pagecount = 1
        end
        modstore.modlist_unsorted.page = 0
 end
@@ -183,13 +180,12 @@ end
 --------------------------------------------------------------------------------
 function modstore.getmodlist(list)
        local retval = ""
-       retval = retval .. "label[10,-0.4;Page " .. (list.page +1) .. 
-                                                       " of " .. (list.pagecount +1) .. "]"
+       retval = retval .. "label[10,-0.4;" .. fgettext("Page $1 of $2", list.page+1, list.pagecount) .. "]"
        
        retval = retval .. "button[11.6,-0.1;0.5,0.5;btn_modstore_page_up;^]"
-       retval = retval .. "box[11.6,0.35;0.28,8.6;BLK]"
-       local scrollbarpos = 0.35 + (8.1/list.pagecount) * list.page
-       retval = retval .. "box[11.6," ..scrollbarpos .. ";0.28,0.5;LIM]"
+       retval = retval .. "box[11.6,0.35;0.28,8.6;000000]"
+       local scrollbarpos = 0.35 + (8.1/(list.pagecount-1)) * list.page
+       retval = retval .. "box[11.6," ..scrollbarpos .. ";0.28,0.5;32CD32]"
        retval = retval .. "button[11.6,9.0;0.5,0.5;btn_modstore_page_down;v]"
        
        
@@ -210,16 +206,17 @@ function modstore.getmodlist(list)
                if details ~= nil then
                        local screenshot_ypos = (i-1 - (list.page * modstore.modsperpage))*1.9 +0.2
                        
-                       retval = retval .. "box[0," .. screenshot_ypos .. ";11.4,1.75;WHT]"
+                       retval = retval .. "box[0," .. screenshot_ypos .. ";11.4,1.75;FFFFFF]"
                        
                        --screenshot
                        if details.screenshot_url ~= nil and
                                details.screenshot_url ~= "" then
                                if list.data[i].texturename == nil then
-                                       print("downloading screenshot: " .. details.screenshot_url)
+                                       local fullurl = engine.setting_get("modstore_download_url") ..
+                                                               details.screenshot_url
                                        local filename = os.tempfolder()
                                        
-                                       if engine.download_file(details.screenshot_url,filename) then
+                                       if engine.download_file(fullurl,filename) then
                                                list.data[i].texturename = filename
                                        end
                                end
@@ -234,15 +231,16 @@ function modstore.getmodlist(list)
                        
                        --title + author
                        retval = retval .."label[2.75," .. screenshot_ypos .. ";" .. 
-                               fs_escape_string(details.title) .. " (" .. details.author .. ")]"
+                               engine.formspec_escape(details.title) .. " (" .. details.author .. ")]"
                        
                        --description
                        local descriptiony = screenshot_ypos + 0.5
-                       retval = retval .. "textarea[3," .. descriptiony .. ";6.5,1.6;;" .. 
-                               fs_escape_string(details.description) .. ";]"
+                       retval = retval .. "textarea[3," .. descriptiony .. ";6.5,1.55;;" .. 
+                               engine.formspec_escape(details.description) .. ";]"
                        --rating
                        local ratingy = screenshot_ypos + 0.6
-                       retval = retval .."label[10.1," .. ratingy .. ";Rating: " .. details.rating .."]"
+                       retval = retval .."label[10.1," .. ratingy .. ";" .. 
+                                                       fgettext("Rating") .. ": " .. details.rating .."]"
                        
                        --install button
                        local buttony = screenshot_ypos + 1.2
@@ -250,9 +248,9 @@ function modstore.getmodlist(list)
                        retval = retval .."button[9.6," .. buttony .. ";2,0.5;btn_install_mod_" .. buttonnumber .. ";"
                        
                        if modmgr.mod_exists(details.basename) then
-                               retval = retval .. "re-Install]"
+                               retval = retval .. fgettext("re-Install") .."]"
                        else
-                               retval = retval .. "Install]"
+                               retval = retval .. fgettext("Install") .."]"
                        end
                end
        end
@@ -272,4 +270,5 @@ function modstore.get_details(modid)
        local retval = engine.get_modstore_details(tostring(modid))
        modstore.details_cache[modid] = retval
        return retval
-end
\ No newline at end of file
+end
+