draw_file_dialog = function() -- border App.color{r=0.6, g=0.7, b=0.6} love.graphics.rectangle('line', Menu_left+5, Menu_top+5, Safe_width-Menu_left-10, Safe_height-Menu_top-10, 5,5) -- ok/cancel buttons (but with wider names) local r = Safe_width-10 r = right_justified_button('cancel', r, Menu_top+5+3, function() reset_file_dialog_state() end) r = right_justified_button('submit', r, Menu_top+5+3, function() File_dialog_callback(File_dialog_input_text) reset_file_dialog_state() end) File_dialog_input_right_margin = r -- input draw_file_dialog_input() -- filtered files App.color(Menu_background) love.graphics.rectangle('fill', Menu_left+5, Menu_bottom+5, Safe_width-Menu_left-10, Safe_height-Menu_bottom-10, 5,5) if Directory_contents == nil then -- on the first frame after dialog is enabled refresh_directory_contents() end local x, y = Menu_left+10, Menu_bottom+10 for _,filename in ipairs(Directory_contents) do if filename:find(File_dialog_input_text) then local w = Font:getWidth(filename) + 10 if x ~= Menu_left+10 and x+w > Safe_width-Menu_left-10 then x = Menu_left+10 y = y+Line_height+10 if y > Safe_height-Menu_bottom-10 then break end end styled_button(filename, x,y, function() File_dialog_callback(filename) reset_file_dialog_state() end) x = x+w+10 end end end