local love = assert( love ) local modal = require( "ui.modal" ) local button = require( "ui.button" ) local map = require( "map.map" ) local t = {} local loadLocation = false local folder = love.graphics.newImage( "icons/load.png" ) folder:setFilter( "nearest", "nearest" ) local loadButton = button.new{ group = "loadModal", name = "load", callback = function() if not loadLocation then return end map.load( loadLocation ) return t:stop() end, visible = false, icon = folder, x = love.graphics.getWidth() / 2 - 300, y = love.graphics.getHeight() / 2 - 150, w = 600, h = 100, } local xIcon = love.graphics.newImage( "icons/x.png" ) xIcon:setFilter( "nearest", "nearest" ) local cancelButton = button.new{ group = "loadModal", name = "cancel load", visible = false, icon = xIcon, callback = function() return t:stop() end, x = love.graphics.getWidth() / 2 - 300, y = love.graphics.getHeight() / 2, w = 600, h = 100 } function t.start() modal.start( t ) loadLocation = loadLocation or map.path button.selected = loadButton loadButton.name = "save to "..loadLocation button.displayGroup( "loadModal", true ) end function t.draw() love.graphics.clear( 0,0,0,1 ) love.graphics.setColor( 0, 0, 1, 0.4 ) button:draw() end function t.directorydropped( path ) loadLocation = path map.path = path loadButton.name = "load from "..map.path return love.filesystem.mount( path, "" ) end return modal.new( t )