diff --git a/main.lua b/main.lua index 2b3ce8b..21cc321 100644 --- a/main.lua +++ b/main.lua @@ -5,6 +5,7 @@ sysUser = os.getenv( "HOME" ) pathDosbox = "/usr/bin/dosbox" pathFDD = sysUser.."/.fdd" urlGameList="http://fanta.56k.es/fdd/fdd_server/archive.lst" +urlGames="http://fanta.56k.es/fdd/fdd_server/archive/" screenSizeW = love.graphics.getWidth() screenSizeH = love.graphics.getHeight() love.window.setTitle( "FDD GUI" ) @@ -16,13 +17,21 @@ monitor.height = 200 monitor.x = (screenSizeW/2)-(monitor.width/2) monitor.y = (screenSizeH/2)-(monitor.height/2) --- FUNCIONES +-- FUNCTIONS function file_check(file_name) 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 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() file_check(pathDosbox) end @@ -41,6 +50,27 @@ function download_gameList(url_gameList) f:close() 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 @@ -58,3 +88,16 @@ function love.draw() love.graphics.draw(monitor.img,monitor.x,monitor.y) draw_floppyDiskName("Darkseed") 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 diff --git a/res/imgs/edge-crt.png b/res/imgs/edge-crt.png deleted file mode 100644 index 6b600a4..0000000 Binary files a/res/imgs/edge-crt.png and /dev/null differ diff --git a/res/imgs/keyboard_key_empty.png b/res/imgs/keyboard_key_empty.png new file mode 100644 index 0000000..b6ca602 Binary files /dev/null and b/res/imgs/keyboard_key_empty.png differ diff --git a/res/imgs/keyboard_key_r.png b/res/imgs/keyboard_key_r.png new file mode 100644 index 0000000..2a4b8cf Binary files /dev/null and b/res/imgs/keyboard_key_r.png differ