download games with r key

master
fanta 3 years ago
parent 2abb4729ec
commit 62e40c9e52

@ -5,6 +5,7 @@ sysUser = os.getenv( "HOME" )
pathDosbox = "/usr/bin/dosbox" pathDosbox = "/usr/bin/dosbox"
pathFDD = sysUser.."/.fdd" pathFDD = sysUser.."/.fdd"
urlGameList="http://fanta.56k.es/fdd/fdd_server/archive.lst" urlGameList="http://fanta.56k.es/fdd/fdd_server/archive.lst"
urlGames="http://fanta.56k.es/fdd/fdd_server/archive/"
screenSizeW = love.graphics.getWidth() screenSizeW = love.graphics.getWidth()
screenSizeH = love.graphics.getHeight() screenSizeH = love.graphics.getHeight()
love.window.setTitle( "FDD GUI" ) love.window.setTitle( "FDD GUI" )
@ -16,13 +17,21 @@ monitor.height = 200
monitor.x = (screenSizeW/2)-(monitor.width/2) monitor.x = (screenSizeW/2)-(monitor.width/2)
monitor.y = (screenSizeH/2)-(monitor.height/2) monitor.y = (screenSizeH/2)-(monitor.height/2)
-- FUNCIONES -- FUNCTIONS
function file_check(file_name) function file_check(file_name)
local f=io.open(file_name, "r") local f=io.open(file_name, "r")
if f==nil then print(file_name.." not found. Install it and try again") os.exit() else print(file_name..": OK") end if f==nil then print(file_name.." not found. Install it and try again") os.exit() else print(file_name..": OK") end
end end
function split_string(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
function check_dependencies() function check_dependencies()
file_check(pathDosbox) file_check(pathDosbox)
end end
@ -41,6 +50,27 @@ function download_gameList(url_gameList)
f:close() f:close()
end end
function download_listGames(file)
local arr = {}
local handle = assert( io.open(file,"r") )
local value = handle:read("*line")
while value do
table.insert( arr, value )
value = handle:read("*line")
if value==nil then else gameName = split_string(value, ";") end
local fi=io.open(pathFDD.."/"..gameName[2], "r")
if fi==nil then
print("Downloading game: "..gameName[2])
local body, code = http.request(urlGames..gameName[2])
local f = assert(io.open(pathFDD.."/"..gameName[2], "wb"))
f:write(body)
f:close()
else
end
end
handle:close()
return arr
end
-- FUNCIONES LOVE -- FUNCIONES LOVE
@ -58,3 +88,16 @@ function love.draw()
love.graphics.draw(monitor.img,monitor.x,monitor.y) love.graphics.draw(monitor.img,monitor.x,monitor.y)
draw_floppyDiskName("Darkseed") draw_floppyDiskName("Darkseed")
end end
function love.keypressed(key)
if key == "escape" then
print("bye bye!")
love.event.quit()
end
if key == "r" then
print("re-check game repository")
download_listGames("/home/fanta/.fdd/archive.lst")
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Loading…
Cancel
Save